VBA Run-time error '5' using Apprentice Server

VBA Run-time error '5' using Apprentice Server

Anonymous
Not applicable
2,319 Views
5 Replies
Message 1 of 6

VBA Run-time error '5' using Apprentice Server

Anonymous
Not applicable

Hello,

 

First time posting, hopefully this is the right place. We recently upgraded to new Dell Precision workstations (Windows 10) and have run into issues when running the Inventor Apprentice server (2019.1.1 is installed). For debugging, I am just trying to open a file on my desktop in apprentice, see code copied below. It gets hung up on the oApprentice.Open.

 

Public Sub TestApprentice()
' Create a new instance of Apprentice.
Dim oApprentice As New ApprenticeServerComponent

' Open a document.
Dim oDoc As ApprenticeServerDocument
Set oDoc = oApprentice.Open("C:\Users\User\Desktop\00031500.ipt")
End Sub

 

As far as I can tell, this looks like an issue with script being unable to find the command in the reference. I have "Autodesk Inventor Object Library" selected as a reference, which I believe is correct. Attached are my references selected from the VBA editor available from Inventor. Also attached is the specific error window.

 

We do not have any other versions of Inventor on the PC. I recently uninstalled and then reinstalled 2019 to no avail (from Autodesk supplied USB stick).

I am able to run SDK samples using the apprentice server, specifically properties.exe under VB.NET, after I recompiled it targeting an x64 cpu. The SDK appears to point to different references. I don't know if my Inventor library is the problem or if it is something deeper in my settings. My experience with VBA is limited, mostly writing code in the VBA editor.

 

Any help or guidance would be greatly appreciated.

 

-Alan

0 Likes
Accepted solutions (1)
2,320 Views
5 Replies
Replies (5)
Message 2 of 6

BrianEkins
Mentor
Mentor
Accepted solution

Apprentice is supported within Inventor's VBA.  Apprentice is a subset of Inventor and includes many of the same libraries that are delivered as part of Inventor.  When you try to use Apprentice using Inventor's VBA, Windows it trying to load those libraries into Inventor and it causes conflicts and problems.  If you have a program that's running in Inventor, (VBA or Add-In), you should just use Inventor.  Opening files invisibly in Inventor is almost as fast as using Apprentice.

 

Apprentice can only be used in processes outside of Inventor.  An EXE that you create will run in its own process so it will support Apprentice.  It's also possible to use Apprentice in another product's VBA.  For example, you could write a VBA program in Excel or Word and use Apprentice and it will work since Apprentice is being loaded into the Excel or Word process.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 6

Anonymous
Not applicable

Brian,

Thank you for the insight, I did not realize running apprentice inside of Inventor would be problematic but it does make sense how you describe it.

 

I would like to use apprentice when calling macros in excel and word, I have a number of scripts that I haven't been able to get up and running on the newer computers. When I try the same code but run from Word 2016, I get a different error (references attached):

 

Run-time error '429': 

ActiveX component can't create object

 

Any insights on how to resolve this? I am not sure if I should make a new topic as this is related but fundamentally different than my original post.

 

-Alan

 

Edit- marking this as accepted as I have found a trove of error 429 things to try and troubleshoot

0 Likes
Message 4 of 6

BrianEkins
Mentor
Mentor

Attached is a Word document that contains a VBA macro that loads Apprentice, opens a document and displays its name.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 5 of 6

Anonymous
Not applicable

Thank  you for continuing to help, I am just getting back to this.

 

I download and run the macro in the word document after changing the file path to a valid ipt file. It does not work and immediately opens a window saying "ActiveX component can't create object" This is in line with the other issues I have been having with the apprentice server.

0 Likes
Message 6 of 6

Anonymous
Not applicable

Found the issue, office 2016 was 32-bit. Changing this to 64-bit resolved the apprentice issues. Now other things are wrong with the code, but it at least is progress!

0 Likes