Need help with VBA late binding in PDM Task

Hi everyone,

I’m a first time poster and novice programmer, and I need some help with editing the PDM Task for converting drawings.

Currently we use the PDM Task add-in to automatically generate PDF, DXF, and STP files during a state transition. This all works fine, but users are complaining that as revisions are created, the folder containing these files is getting too cluttered, so I want to modify the Task’s code to automatically move older revisions to a subfolder so that only the latest revision is stored in the main folder.

Thanks to the internet, I’ve kludged together the following code and added it as a subroutine, but the first hurdle I run into is that I have to change it to late binding due to it being run via the Task add-in. I’ve found references on how to do that for the EdmVault object, but the rest eludes me.
Is there anyone who might be able to point me in the right direction as far as converting the remaining code to late binding? From there I can continue troubleshooting on my own, but if anyone sees any obvious errors in the rest of my code, I would really appreciate any feedback.

Thanks in advance for any guidance or suggestions you can provide.

Sub MoveExistingRevisions(modelPath, modelFileName)

Dim vault As EdmVault5
Dim releaseFolder(1) As EdmSelItem
Dim bg As IEdmBatchGet
Dim listFiles As Variant


Set vault = CreateObject("ConisioLib.EdmVault")

'set the path names for the existing Release Files folder and the new folder for Older Revisions
releaseFilePath = Left(modelPath, InStrRev(modelPath, "\")) & "Release Files"
oldRevFilePath = releaseFilePath & "\Older Revisions"


'ensure there is a local copy of all files in the existing Release Files folder
releaseFolder(0).mlDocID = 0
releaseFolder(0).mlProjID = vault.GetFolderFromPath(releaseFilePath).ID

Set bg = vault.CreateUtility(EdmUtil_BatchGet)
bg.AddSelection vault, releaseFolder()
bg.CreateTree 0, EdmGetCmdFlags.Egcf_SkipExisting
bg.GetFiles 0, Nothing

'check if previous revisions exist in the Release Files folder
listFiles = Dir(releaseFilePath & "\*" & modelFileName & "*")
If listFiles <> vbaNullString Then
     'create the Older Revisions subfolder if it does not already exist
     SHCreateDirectoryEx ByVal 0&, StrPtr(oldRevFilePath), ByVal 0&
     Do While Len(listFiles) > 0
         'move the file to the older revisions folder
         Debug.Print listFiles
         existingFileName = releaseFilePath & "\" & listFiles
         newFileName = oldRevFilePath & "\" & listFiles
         Set FSO = CreateObject("Scripting.FileSystemObject")
         FSO.MoveFile existingFileName, newFileName
         'Next File
         listFiles = Dir
     Loop
End If

End Sub

You’re almost there.

Change this

Dim vault As EdmVault5
Dim releaseFolder(1) As EdmSelItem
Dim bg As IEdmBatchGet
Dim listFiles As Variant

to

Dim vault As object
Dim releaseFolder(1) As object
Dim bg  As object
Dim listFiles As Variant

Late binding means that the types are only known during runtime so you can only use object for your type.