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

Unable to export the current BOM config

Hello,

I need to export a BOM to Excel, using a BOM XML template, but without modifying the BOM current structure.

So I use :

  • save current BOM config in "BOM Tempo.xml"
  • load existing BOM config
  • ....
  • load "BOM Tempo.xml"

The problem is the saved file "BOM Tempo.xml" does not match the current BOM config, it is always the same.

The code I use : 

Sub test()

Set oAss = ThisApplication.ActiveDocument
Set oBOM = oAss.ComponentDefinition.BOM

'Define file name to export current BOM config
BOM_tempo = Environ("temp") & "\BOM_tempo.xml"

'if existing file, delete it
On Error Resume Next
Kill BOM_tempo
On Error GoTo 0

'Export active BOM config, in order to restore it 
Call oBOM.ExportBOMCustomization(BOM_tempo)

'Load the custom BOM config file
oBOM.ImportBOMCustomization ("c:\temp\custom BOM.xml")

'...some code...

'Restore the original BOM config file
Call oBOM.ImportBOMCustomization(BOM_tempo)

End Sub

Normally I should have the same BOM config that I had at the beginning...