Hello,
We are trying to run Inventor 2020 VBA scripts from Excel 2013, but got the issue "Run-time error '5': Invalid procedure call or argument" at the line "Set oApprentice = New ApprenticeServerComponent"
in the below copied code.
We are using Excel 2013 64bit and Inventor Professional 2020 64bit. Request your help to resolve this.
Private Function InitInvAPP(oTopDoc As Inventor.AssemblyDocument) As Boolean
Set invApp = ThisApplication
Set oApprentice = New ApprenticeServerComponent
Set eXcelAPP = GetObject(, "excel.application")
If eXcelAPP Is Nothing Then
InitInvAPP = False
Exit Function
End If
On Error Resume Next
Set oTopDoc = invApp.ActiveDocument
If Err.Number <> 0 Then
InitInvAPP = False
Exit Function
End If
If oTopDoc Is Nothing Then
InitInvAPP = False
Else
InitInvAPP = True
End If
End Function
You are not able to use Inventor.Application (ThisApplication) and Inventor.ApprenticeServerComponent in the same runtime.
You need to add reference to Autodesk Inventor Object Library in VBA project
And try this code snippet for test (It works for me)
Private Sub InitInvAppTest()
'Set invApp = ThisApplication
Dim oApprentice As Inventor.ApprenticeServerComponent
Set oApprentice = New ApprenticeServerComponent
Debug.Print oApprentice.InstallPath
End Sub
Expected result in Immediate window is similar to this: c:\program files\autodesk\inventor 2020\
Can't find what you're looking for? Ask the community or share your knowledge.