PDM API GetEnumeratorVariable no variable found

I’m writing a code to write something into the Data Card of a file, but it doesn’t work and i don’t know why. Can anyone help me please.

The GetEnumeratorVariable returns nothing, but they are some on the data card (see image below)

Here is my code (I commented de Lock and Unlock line so that i don’t add to many version on my test Part and locked the file manualy on my computer and edited the paths and Login info to protect my company)

Sub Auschecken()
    Dim myVault         As New EdmVault5
    Dim epdmfile        As IEdmFile17
    Dim epdmFolder      As IEdmFolder12
    Dim eVar            As IEdmEnumeratorVariable5
    Dim FoPath          As String
    Dim FiPath          As String
    Dim ArtNr           As String
    ' Login
        If Not myVault.IsLoggedIn Then myVault.Login "abcdef", "abcdef", "abcdef"

    FoPath = "C:\abcdef\01_\1051-1100\xxxx"
    FiPath = FoPath & "\" & "drucker2.sldprt"

    Set epdmFolder = myVault.GetFolderFromPath(FoPath)
    Set epdmfile = myVault.GetFileFromPath(FiPath)
    ArtNr = "1234"
    'If Not epdmfile.IsLocked Then epdmfile.LockFile epdmFolder.ID, epdmFolder.ID
    Set eVar = epdmfile.GetEnumeratorVariable(FiPath) ' This comes up empty
    eVar.SetVar "DT-Art.-Nr.", "Standard", ArtNr
    'If epdmfile.IsLocked Then epdmfile.UnlockFile epdmFolder.ID, " "
End Sub

This is the Error VBA shows me:
Which translates to: “The file format plugin cannot process the file because a component is missing”

Thank you very much.

Your code seems to work on my end when adapted to my Sandbox vault. I’ve tried everything I can think of to reproduce your error within my VBA editor.

With that said, how are you running this code? Is this through the built-in SW macro editor, a standalone VB.NET application, etc.?

Additionally, assuming your in the macro VBA editor, what DLL are you referencing in your Tools → References dialog? Does the PDM Type Library year match the one you’re running with your vault?

I’m running it over the Excel VBA editor, because after i solve this error, i have to implement it for a whole list of documents, that i have on Excel. I’m currently not at work so I’m not sure on wich year our PDM runs, but I have the 2020 PDM library and we run the 2020 Solidworks, so PDM should probably be the same year.

Just shooting in the dark here. The error happens in you

  • do not uncheck prefer 32 bits in Visual Studio project properties,
  • Have some embed interops = true for PDM DLLs.
  • An serial numbering add-in that is linked to a variable might be the reason why you have this issue
  • Possibility your files and PDM are not the same years. I think PDM has trouble if the file is one year ahead.