Message 1 of 3
Export BOM code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been looking all over the forums for guidance but seem to have fallen short. I have some code to export an assembly BOM to a text tab delimited file and it also saves it to a network folder but a weird thing keeps happening...
The info keeps reorganizing from what it should be see attached. I also need to name the file name that same as the assembly file name.
File that is named "BOM-StructuredAllLevels" is from the macro and the file named "File Name needs to be here" was created from Bill of Materials, export Bill of Materials, structured and export all levels, browse to the network drive, name file and change typr to text (tab delimited), and save.
macro code...
Public Sub BOMExport() ' Set a reference to the assembly document. ' This assumes an assembly document is active. Dim oDoc As AssemblyDocument Set oDoc = ThisApplication.ActiveDocument ' Set a reference to the BOM Dim oBOM As BOM Set oBOM = oDoc.ComponentDefinition.BOM ' Set the structured view to 'all levels' oBOM.StructuredViewFirstLevelOnly = False ' Make sure that the structured view is enabled. oBOM.StructuredViewEnabled = True ' Set a reference to the "Structured" BOMView Dim oStructuredBOMView As BOMView Set oStructuredBOMView = oBOM.BOMViews.Item("Structured") ' Export the BOM view to a Text File Tab Delimited file oStructuredBOMView.Export "I:\Inventor BOMs\BOM-StructuredAllLevels.txt", kTextFileTabDelimitedFormat End Sub