Hello,
I'm working on a macro to copy tree a file in PDM, however there seems to be an issue with linking the library references. My macro, pasted below, seems to be straightforward. The function "pdmVault.CopyTree" expects the sixth parameter to be of type "EdmCopyTreeOptions". But when running the macro I get "Compile error: User-defined type may not be passed ByVal". The VBA seems to not recognize the EdmCopyTreeOptions type within the function and thinks that it's a user-defined type. I'm not sure how the function within PDM's library reference expects a type that it doesn't recognize. I have the reference "PDMWorks Enterprise 2024 Type Library" in my environment and I'm using SolidWorks 2024.
I found this post from a year ago that seems to be experiencing the same issue, so it's not an issue unique to myself:
Sub Main()
Dim pdmVault As IEdmVault19
Dim Folder As IEdmFolder9
Dim destFolder As String
Dim aFile As IEdmFile5
Dim aFolder As IEdmFolder5
Dim Path As String
Dim copyTreeOptions As EdmCopyTreeOptions
Set pdmVault = New EdmVault5
Call pdmVault.LoginAuto("PDMVault", 0) 'YOUR VAULT NAME HERE
Set Folder = pdmVault.RootFolder
' Destination Folder
destFolder = "C:\\PDMVault\\Your\\Destination\\Path" 'YOUR DESTINATION PATH HERE
Set Folder = pdmVault.getFolderFromPath(destFolder)
' Source File
Path = "C:\\PDMVault\\Your\\File\\Path.SLDPRT" 'YOUR FILEPATH HERE
Set aFile = pdmVault.getFileFromPath(Path, aFolder)
' Initialize and set copyTreeOptions
copyTreeOptions.mbsPrefix = "Tst_"
copyTreeOptions.mbsSuffix = ""
copyTreeOptions.mbIncludeDrawings = True
copyTreeOptions.mbUseLatestVersion = True
' Debugging statements
Debug.Print ("File ID: " & aFile.ID)
Debug.Print ("Folder ID: " & aFolder.ID)
' Pass copyTreeOptions directly
Call pdmVault.CopyTree(aFile.ID, aFolder.ID, destFolder, False, False, copyTreeOptions, 0)
End Sub
