I'm currently trying to implement a function in a macro but I'm stuck... I therefore appeal to your knowledge! I wish I could open the data map of a PDM file via a VBA macro but the result I get leaves me perplexed ahaha
Here is the piece of code we are interested in:
Global File As IEdmFile13
Global Folder As IEdmFolder10
Set Folder = vault.GetFolderFromPath(fs.GetParentFolderName(CheminFichier))
Set File = Folder.GetFile(fs.GetFileName(CheminFichier))
Dim CardView As IEdmCardView63
Set CardView = Folder.CreateCardView2(File.ID, 0, 400, 100, , 253)
CardView.ShowWindow (True)
By testing quickly, I think that the function only displays the map without access to it from an editing point of view, so you have to "place" it in a window that has a background (basically on a userform with a gray background it appears normally, otherwise in the macro editor it appears in transparency)
Or by creating a userform that contains buttons and calls the snippet of code. Or put it directly in the procedure for activating the form. On the other hand, you need to retrieve the height and width information of the card to resize the form correctly and display the whole map. In the help of the api if you are in vb#net it is this piece of code:
' Get the size needed to display the card
Dim width As Integer
Dim height As Integer
view.GetCardSize(width, height)
Otherwise roughly in vba:
Private Sub UserForm_Activate()
Dim File As IEdmFile13
Dim Folder As IEdmFolder10
Dim width As Long
Dim height As Long
Set vault = New EdmVault5
vault.LoginAuto "_TDM_PROD", 0
CheminFichier = "C:\xxx\xxx"
Set Folder = vault.GetFolderFromPath(CheminFichier)
Set File = Folder.GetFile("xxx.SLDPRT")
Set CardView = Folder.CreateCardView2(File.ID, 0, 400, 100, , 253)
CardView.GetCardSize width, height
UserForm1.width = width + 80 'à affiner pour la largeur
UserForm1.height = height + 10 'à affiner pour la hauteur
CardView.ShowWindow (True)
End Sub
Public Sub UserForm_Activate()
Dim l As Long
Dim h As Long
Set Folder = vault.GetFolderFromPath(fs.GetParentFolderName(CheminFichier))
Set File = Folder.GetFile(fs.GetFileName(CheminFichier))
Dim CardView As IEdmCardView63
Set CardView = Folder.CreateCardView2(File.ID, 0, 400, 100, , 253)
CardView.GetCardSize l, h
UserForm1.Width = l + 80
UserForm1.Height = h + 80
CardView.ShowWindow (True)
End Sub
Thank you @Cyril.f ! Not the first time you manage to unblock me with a macro story ahaha I'm going to dig on my own too and I'll make a return too if I find the solution!
I've coded quite a few whether it's on SW/PDM/Excel/Word/Outllook so when I can help.
So after testing, on SW it's just a problem of declaring variables. Excel does well without declaring the CardView variable. In the SW api you have to add:
Dim CardView As IEdmCardView63 'ou IEdmCardView64 ça dépend de la version majeur de PDM
it finally seems to show it to me!! I had declared the variables but within the procedure of the UserForm_Activate ... by putting it outside the instruction it shows me it! I still have to dig because on my side it displays it as an image in the UserForm I can't modify or do anything on it
Yes, that's the problem, the map displayed is only a "dead" object. You have to look in the options and it seems to me that you have to run other functions to then apply the changes