This is what I have so far. It extracts the Quantity and Part Number, but the comments are not coming in.
What did I do wrong for the comments?
Sub BOM_Export()
Dim oApp As Application
Set oApp = ThisApplication
If oApp.ActiveDocument.DocumentType = kAssemblyDocumentObject Then
Dim oAssyDoc As AssemblyDocument
Set oAssyDoc = oApp.ActiveDocument
Dim oAssyCompDef As AssemblyComponentDefinition
Set oAssyCompDef = oAssyDoc.ComponentDefinition
'Dim excel_app As Excel.Application
' Create the Excel application.
Set excel_app = CreateObject("Excel.Application")
' Uncomment this line to make Excel visible.
excel_app.Visible = True
'Create new workbook
Call excel_app.Workbooks.Add
Dim oBomR As BOMRow
Dim oBOMPartNo As String
Dim oBomComments As String
With excel_app
.Range("A1").Select
.ActiveCell.Value = "Quantity"
.Range("B1").Select
.ActiveCell.Value = "Part Number"
Dim ad As AssemblyDocument
Set ad = ThisApplication.ActiveDocument
Dim acd As AssemblyComponentDefinition
Set acd = ad.ComponentDefinition
Dim bom As bom
Set bom = acd.bom
' Depending on what you need
bom.StructuredViewEnabled = True
bom.StructuredViewFirstLevelOnly = False
bom.PartsOnlyViewEnabled = True
' Structured BOM view is second if it's enabled
' Dim bv As BOMView
' Set bv = bom.BOMViews(2)
'Iterate through parts only BOM View
Dim i As Integer
For i = 1 To oAssyCompDef.bom.BOMViews(3).BOMRows.Count
'Set oBomR to current BOM Row
Set oBomR = oAssyCompDef.bom.BOMViews(3).BOMRows(i)
'Get Current Row part number from part
oBOMPartNo = oBomR.ComponentDefinitions(1).Document.PropertySets(3).ItemByPropId(5).Value
'Write values to spreadsheet
.Range("A" & i + 1).Select
.ActiveCell.Value = oBomR.TotalQuantity 'Quantity value
.Range("B" & i + 1).Select
.ActiveCell.Value = oBOMPartNo
.Range("C" & i + 1).Select
.ActiveCell.Value = oBomComments
Next i
End With
Else
Exit Sub
End If
End Sub