Easy export BOM to excel with template options

Easy export BOM to excel with template options

Milan_Nosil
Advocate Advocate
990 Views
2 Replies
Message 1 of 3

Easy export BOM to excel with template options

Milan_Nosil
Advocate
Advocate

Hello all,

i have a small problem...

Do you have someone an iLogic code to export the BOM (from assembly) to excel using a template?

 

I found some forum posts, but all posts contain code that does not work for me.

I would need to generate a BOM that would look like a template.

 

Thank you for any advice

Milan

 

0 Likes
991 Views
2 Replies
Replies (2)
Message 2 of 3

dgreatice
Collaborator
Collaborator

Hy,

 

 

 

try This:

 

Dim oApp As Application
Dim oDoc As Document
Dim oAD As AssemblyDocument
Dim oACD As AssemblyComponentDefinition
Dim oBOM As BOM
Dim oBOMStructure As BOMView
Dim oBomRow As BOMRow

oApp = ThisApplication
oDoc = oApp.ActiveDocument

If oDoc.DocumentType = kAssemblyDocumentObject Then
    oAD = oApp.ActiveDocument
    oACD = oAD.ComponentDefinition
    oBOM = oACD.BOM
    
    oBomTemplatePath = "C:\My BOM Template\My Template.xml"
    BomExcelPath = "C:\Exported BOMs\MyExportedBOM.xls"
    
    oBOM.StructuredViewEnabled = True
    Call oBOM.ImportBOMCustomization(oBomTemplatePath)
    oBOM.StructuredViewFirstLevelOnly = False
    oBOMStructure = oBOM.BOMViews.Item("Structured")
    Call oBOMStructure.Export(BomExcelPath, kMicrosoftExcelFormat)
Else
    MsgBox("You can't Access this command", vbCritical, "Error")
    Exit Sub
End If

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 3 of 3

Milan_Nosil
Advocate
Advocate

Hi,

thank you very much, but I seeing a bug: The parameter is not correct. (Exception based on HRESULT value: 0x80070057 (E_INVALIDARG)).

 

I'm sorry I did not specify a template. I mean template .xls (or .xlsx). It's about adjusting the size of the columns. This is because I don't want to change the size of the columns in each generated BOM.xls.

 

Thank you.

Milan Nosil

0 Likes