PDM API: Get and set a card variable in VBA

I need to merge two variables not mapped to SW custom properties, with a custom PDM TASK.

I am familiar with VBA macro and managed to customize other TASKS, with get latest, checkin and checkout operations.

I have not experience in manipulating the card variables and I have no access to visual studio or the necessary experience with C# or languages other than VBA.

 

I have to loop all configurations to read Variable1 and Variable2, if Variable1 is empty and Variable2 is not empty I merge Variable1 = Variable2

 

pseudo code below (modified from here ):

Dim edmVault As IEdmVault5 
Dim filePath As String 
Dim swFile As IEdmFile5 
Dim swFolder As IEdmFolder5

'Variable to read 
Dim variableName1 As String 

'Variable to merge in Variable1
Dim variableName2 As String

Dim varEnum As IEdmEnumeratorVariable5  

Sub main

Set edmVault = New EdmVault5  

'Login into the vault. Replace "YourVaultName" with your actual vault name
edmVault.LoginAuto "YourVaultName", 0  

' Replace with your actual file path. Dynamically generated for TASK
filePath = "C:\\PDM_Vault\\YourFile.SLDPRT"

'Get the PDM file from its full path
Set swFile = edmVault.GetFileFromPath(filePath, swFolder)  

'Checkout the file if checked in
If Not swFile.IsLocked Then
    swFile.LockFile swFolder.ID, 0
End If 

'Datacard variable
Set varEnum = swFile.GetEnumeratorVariable

'PLACEHOLDER: 
'to be replaced with a loop that enumerates all configurations in swFile and 
' read variable1 and variable2 from each of them

' Q: How to check the configurations from PDM database for swFile?

variableName1 = "Description1"  ' Example variable
variableName2 = "Description2"  ' Example variable

varEnum.GetVar variableName1, "configuration name" '??pseudocode

'set the variable value for a certain configuration; 

If (Variable1 = "") and (Variable2 <> "") Then

Variable1 = Variable2

End if

varEnum.SetVar variableName2, "@", Variable1 
'checkin and realease the file to avoid access violation

End Sub