VBA programming in Microsoft Access, referencing Apprentice, to extract BoM data, roadblock
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I feel like I'm sitting in the driver's seat of a powerful and well appointed car. I've managed to start the engine, but the gears are hidden, in plain sight.
The challenge: without Inventor installation, merge the BOM data from several hundred assembly and fabrication drawings with data in a Microsoft Access application.
My current version of the solution is to install Inventor View (installed inventor View 1.0 Build 287, Release 2022.2.1) which includes Apprentice components and write VBA code in Access to batch extract data. The data should come in the same format that Inventor uses when exporting structured BoM to Excel, less the thumbnails.
So far I am able to open an Assembly
as follows, with a couple rudimentary checks to see that it is working, with the exception as noted
Something is amiss - the runtime error states the Name property of ComponentOccurrence is a method, Which makes no sense, unless one of you knows something that I can't put my finger on.
Function OpenFileInApprentice(strfilepath As String) As Boolean
Dim osvr As New Inventor.ApprenticeServerComponent
Dim odoc As Inventor.ApprenticeServerDocument
Dim colOccurences As ComponentOccurrences
Dim oCompOccurrence As Inventor.ComponentOccurrence
Set odoc = osvr.Open(strfilepath)
Debug.Print odoc.DocumentType
Debug.Print odoc.DisplayName
Debug.Print "Occurences: "; colOccurences.Count
For Each oCompOccurrence In colOccurences
' Display information about the current component.
Debug.Print oCompOccurrence.Name ' generates run time error - Method 'Name' of object ComponentOccurrence failed
Next
' routine practice - release all open objects
set oCompOccurrence = Nothing
set colOccurences = Nothing
Set odoc = Nothing
Set osvr = Nothing
End Function
Above code returns
12291
AM22P3006.iam
Occurences: 25