Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

@Darkforce_the_ilogic_guy 

 

Can you try this code and see if it works in iLogic? Please change your excel file and excel sheet if needed, I had copied the same from the code you provided.

 

Public Sub Main()

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")

Call ExportToExcel(oBOMView.BOMRows)
End Sub

Public Function ExportToExcel(bRows As BOMRowsEnumerator)
ExcelFile ="C:\SolidCAD\Inventor Training Files\iLOGIC\Beam\Beam Assembly - BOM.xlsx"
ExcelSheet = "TEST"

Dim row As Integer
row = 5

GoExcel.CellValue(ExcelFile,ExcelSheet,"B4") = "Item"
GoExcel.CellValue(ExcelFile,ExcelSheet,"C4") = "QTY"
GoExcel.CellValue(ExcelFile,ExcelSheet,"D4") = "DESCR"
GoExcel.CellValue(ExcelFile,ExcelSheet,"E4") = "Material"

Dim bRow As BOMRow
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")


GoExcel.CellValue(ExcelFile,ExcelSheet,"B" & row) = bRow.ItemNumber
GoExcel.CellValue(ExcelFile,ExcelSheet,"C" & row) = bRow.ItemQuantity
GoExcel.CellValue(ExcelFile,ExcelSheet,"D" & row) = docPropertySet.Item("Description").Value
GoExcel.CellValue(ExcelFile,ExcelSheet,"E" & row) = docPropertySet.Item("Part Number").Value

row = row + 1
Next

GoExcel.Save
GoExcel.Close
GoExcel.ClearCache

End Function

 

Hope this will be helpful.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn