Get variable value from folder datacard

Hi! I’m trying to get the value of a variable from a PDM folder datacard with a VBA macro.

From the API documentation I understand that I can cast a IEdmFolder5 object to the IEdmEnumeratorVariable5 interface. I then would like to use the GetVar method to access the variable value.

Here is the code:

Dim pdmVault As Object

Const VAULT_NAME As String = "VAULT_BL_TEST"
Const VARIABLE_NAME As String = "_BL_DESCRIZIONE"
Const FILE_PATH As String = "C:\VAULT_BL_TEST\DISEGNI\MACCHINE\CARRELLI\A077\"

Sub main()

    Set pdmVault = CreateObject("ConisioLib.EdmVault")

    pdmVault.LoginAuto VAULT_NAME, 0	
    
    If pdmVault.IsLoggedIn Then

        Dim folder As IEdmFolder5
        Set folder = pdmVault.GetFolderFromPath(FILE_PATH)

        Dim folderId As Integer
        folderId = folder.ID

        Dim varEnum As IEdmEnumeratorVariable5
        Set varEnum = folder

        Dim status As Boolean
        Dim varValue As String
        status = varEnum.GetVar(VARIABLE_NAME, "", varValue)
        Debug.Print(" varValue : " & varValue )
        
    Else
        Err.Raise vbError, "User not connected to the Vault"
    End If
    
End Sub

The code return varValue as an empty string, but a True status.

In VBE I added the reference to the PDM library:
SLDWORKS_nDYfK0ieD2

The folder datacard is as per image below

Where am I wrong?

Thanks in advance.

I’m not an expert with the PDM API but try

Dim varValue As Variant

Source: https://r1132100503382-eu1-3dswym.3dexperience.3ds.com/?_gl=1*bx2uru*_ga*MTEzOTg2MjIwNy4xNjc0Nzk3NTE2*_ga_XQJPQWHZHH*MTY3ODg4MjMzOS4yOC4xLjE2Nzg4ODMxNDguNjAuMC4w#community:yUw32GbYTEqKdgY7-jbZPg/iquestion:MPuluGBfQ5KBBigcwCLa8w (check reply from Jeff Sweeney)

1 Like

Thank you! I should have checked the old forum, and checked the VariableType

I lost count on how may times I found a solution from one of your post. Thanks again.

1 Like