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

ilogic export BOM

Hello,
I'm using the following rule:

 

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

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\Szablon.xlsx")

xlWorksheet = xlWorkbook.Worksheets.Item("BOM")

Dim row As Integer
row = 3

'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("A" & row).Value = bRow.ItemNumber
xlWorksheet.Range("B" & row).Value = docPropertySet.Item("Part Number").Value
xlWorksheet.Range("C" & row).Value = bRow.ItemQuantity
xlWorksheet.Range("D" & row).Value = docPropertySet.Item("Stock number").Value
xlWorksheet.Range("E" & row).Value = docPropertySet.Item("Vendor").Value
xlWorksheet.Range("F" & row).Value = docPropertySet.Item("Description").Value
xlWorksheet.Range("G" & row).Value = docPropertySet.Item("Cost").Value


row = row + 1
Next

oNow = DateString & "_" & TimeString
oNow = oNow.Replace("/","_")
oNow = oNow.Replace(":","_")
xlWorkBook.SaveAs(Filename:="C:\Temp\BOM-" & oNow & ".xlsx")

xlWorkbook.Close (True)
xlApp.Quit

 

 

 

The problem is that using this rule after export the new element adds to my list at the end of my xls template.

 

image.png

image.png

 

 

 

 

If I use the export icon from .iam - then structural BOM exports correctly:

 

image.png

 

And I get the correct xls:

 

 

image.png

 

Any idea why this is happening ...

 

 

Thanks

Ed