From the post shown above here it is again
https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/ilogic-code-to-export-bom-to-excel-file...
Message 11 has this rules that loops through the BOm and returns a few columns the user specifies. You need to create an excel file in this location this is simply a place holder to dump the data and then it copies to another excel file.
xlWorkbook = xlApp.Workbooks.Open("C:\Temp\Test.xlsx")
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM
oBOM.PartsOnlyViewEnabled = True
Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews.Item("Parts Only")
xlApp = CreateObject("Excel.Application")
'comment out or change to false
'in order to not show Excel
xlApp.Visible = True
xlWorkbook = xlApp.Workbooks.Open("C:\Temp\Test.xlsx")
xlWorksheet = xlWorkbook.Worksheets.Item("Sheet1")
Dim row As Integer
row = 5
xlWorksheet.Range("B4").Value = "ITEM"
xlWorksheet.Range("C4").Value = "QTY"
xlWorksheet.Range("D4").Value = "DESC"
xlWorksheet.Range("E4").Value = "Part Number"
'Dim bRow As bomRow
bRows = oBOMView.BOMRows
For Each bRow In bRows
Dim rDoc As Document
rDoc = bRow.ComponentDefinitions.Item(1).Document
Dim docPropertySet As PropertySet
docPropertySet = rDoc.PropertySets.Item("Design Tracking Properties")
xlWorksheet.Range("B" & row).Value = bRow.ItemNumber
xlWorksheet.Range("C" & row).Value = bRow.ItemQuantity
xlWorksheet.Range("D" & row).Value = docPropertySet.Item("Description").Value
xlWorksheet.Range("E" & row).Value = docPropertySet.Item("Part Number").Value
row = row + 1
Next
oNow = DateString & "_" & TimeString
oNow = oNow.Replace("/","_")
oNow = oNow.Replace(":","_")
xlWorkBook.SaveAs(Filename:="C:\Temp\SampleNew_" & oNow & ".xlsx")
xlWorkbook.Close (False)
xlApp.Quit

Message 16 has a different approach to export the complete BOM. This has no Column sorting and will simply dump all of the BOM to the excel file. You can add in some column customization with export options, there will be many more samples available on how to do this. I run a similar one to this with all BOM sorting and splitting of welding vs assembly parts in excel through excel macros.
Create the excel File at this location
ExportBOMToExistingExcel("C:\Temp\Export All.xlsx", "BOM")
Create the Temporary excel File at this location
oTemporaryExcelFile = "C:\Temp\Test_ExportAll.xlsx"
Sub Main()
ExportBOMToExistingExcel("C:\Temp\Export All.xlsx", "BOM")
End Sub
Sub ExportBOMToExistingExcel(oxlName As String, oxlSheet As String)
'ExportBOMToExistingExcel - by MechMachineMan on Inventor Customization Forums
'Purpose: To export a BOM to an existing excel file as a workaround to inventor's native behaviour of
' wiping the destination file of the export.
'Method: This sub will simply create a temporary excel file, and then copy the sheet to the destination document.
'Change this temp file to something that works for you better, if desired.
'Is currently a Generic location To make it portable.
oTemporaryExcelFile = "C:\Temp\Test_ExportAll.xlsx"
Dim xlApp As Object
Dim workingwb As Object
Try
ExportBOMToTemp(oTemporaryExcelFile)
xlApp = CreateObject("Excel.Application")
workingwb = xlApp.Workbooks.Open(oxlName)
sourcewb = xlApp.Workbooks.Open(oTemporaryExcelFile)
sourcews = sourcewb.Sheets(1)
sourcews.Copy(After:=workingwb.Sheets(workingwb.Sheets.Count))
workingws = workingwb.Sheets(workingwb.Sheets.Count)
workingws.Name = oxlSheet
sourcewb.Close()
Catch
MsgBox("Error During Export Encountered!")
End Try
Try
xlApp.Visible = True
workingwb = Nothing
xlApp = Nothing
Catch
End Try
releaseObject(workingws)
releaseObject(sourcewb)
releaseObject(workingwb)
releaseObject(xlApp)
End Sub
Sub ExportBOMToTemp(oTempFile As String)
'Do not mod where tempfile appears; only mod to get parts only if desired.
Dim oDoc As AssemblyDocument
oDoc = ThisDoc.Document
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM
oBOM.StructuredViewFirstLevelOnly = False
oBOM.StructuredViewEnabled = True
Dim oStructuredBOMView As BOMView
oStructuredBOMView = oBOM.BOMViews.Item("Structured")
oStructuredBOMView.Export(oTempFile, kMicrosoftExcelFormat)
End Sub
Sub releaseObject(ByVal obj As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub

If this solved a problem, please click (accept) as solution.
Or if this helped you, please, click (like)
Regards
Alan