Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBA Run time error '5' in Apprentice Server Component

1 REPLY 1
Reply
Message 1 of 2
Anonymous
295 Views, 1 Reply

VBA Run time error '5' in Apprentice Server Component

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

 

1 REPLY 1
Message 2 of 2
Michael.Navara
in reply to: Anonymous

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.

Post to forums  

Autodesk Design & Make Report