AnsweredAssumed Answered

VBA Compile error: Expected Function or Variable

Question asked by Nicholas Johnson on Nov 9, 2020
Latest reply on Nov 10, 2020 by Nicholas Johnson

I'm writing a Solidworks macro that works with some data card values, and am just getting into the PDM API.  I have an error I just cannot figure out.  I think it has something to do with the naming of the function that I need to use "SetVar" being taken by something else, but I have no clue what to do if there is a conflict.


Here's the function, full code is kind of long, but nowhere in it is there a module/function/sub/anything named "SetVar".  It just gets a variable from the data card of the main config, and then also has an option to set the variable in other configs.



Function getChangePDMVar(sFullFileName As String, sVarName As String, Optional sConfigName As String = "", Optional newValue3 As String = "") As String
Dim pdmVault5 As EdmVault5
Dim File5 As IEdmFile5
Dim Folder5 As IEdmFolder5
Dim pdmEnVar5 As IEdmEnumeratorVariable5
Dim pdmEnVar8 As IEdmEnumeratorVariable8
Dim pdmVar5 As Variant
Dim boolstatus As Boolean
Set pdmVault5 = New EdmVault5
pdmVault5.LoginAuto "PDM", 0
If pdmVault5.IsLoggedIn Then

Err.Raise vbError, "User is not logged into the vault"
End If

Set File5 = pdmVault5.GetFileFromPath(sFullFileName, Folder5)
If File5 Is Nothing Then
End If

Set pdmEnVar5 = File5.GetEnumeratorVariable
On Error GoTo 0
boolstatus = pdmEnVar5.GetVar(sVarName, "@", pdmVar5)
If Not newValue3 Like "" Then
boolstatus = pdmEnVar5.SetVar(sVarName, sConfigName, newValue3)
End If
Set pdmEnVar8 = pdmEnVar5
pdmEnVar8.CloseFile (False)

getChangePDMVar = pdmVar5

End Function

I found I could get exactly the same error in a whole new macro with basically nothing in it.


Sub main()
Dim boolstatus As Boolean
Dim pdmEnVar5 As IEdmEnumeratorVariable5

boolstatus = pdmEnVar5.SetVar("", "", "")
End Sub

If anyone can see my mistake or has a better way to set a variable, I'm open to anything at this point.