Apparently it is neither enough to provide BOM export to Excel interactively in the Inventor product as explained in this earlier post nor is it sufficient that we provide iLogic snippets to export the BOM to Excel via:
ThisBOM.Export("Parts Only", "fileName", kMicrosoftExcelFormat)
The crowd still wants to have a go at it the hard way by writing VBA code J
So let's give the crowd what it is clamoring for. "Panem et circenses" as the Romans used to say.
The VBA code that I came up with can be inspected and downloaded here.
A couple of conditions have to be met in order to successfully run the code (if these conditions are not met, you will get nagging warning dialogs anyway):
- First, add the Microsoft Excel Object Library to your VBA project by using the Tools > References menu in the VBA editor. This is a one-time operation.
- Make sure to have a drawing active in your Inventor session
- Close any open Excel sessions
- Select a parts list on the drawing before running the code.
Important: the macro will expand the parts list automatically to all levels, before exporting it to Excel.
At runtime, the code asks you to give a full path to an Excel filename.
If the file does not exist it will be created.
If the file exists, it will be reused
The parts list will be created on a sheet called "BOM". In the case of an existing Excel file, all other sheets will be preserved.
If you want to put the parts list information on a different sheet, rename the string "BOM" in the first line of the code to something else.
Const Sheetname = "BOM"
Here is a snapshot of a sample drawing parts list that was created with the "Structured (legacy)" option.
Here is the result in Excel on the sheet "BOM", after running the macro.
Hopefully I have now covered one more avenue to go from a BOM to Excel.
Bob



Subscribe
Comments