Excel Export VBA append to exisiting sheet

Excel Export VBA append to exisiting sheet

Ruffy85
Collaborator Collaborator
531 Views
3 Replies
Message 1 of 4

Excel Export VBA append to exisiting sheet

Ruffy85
Collaborator
Collaborator

Good Morning Ladies and Gentleman,

we are using a VBA Makro to Export our Drawing Partlist It works ok. But i will improve that one.

Can i ask if its possible to export a bomlist to an exisiting File? The new Bomlist should insert as a new Table?

I think the pnly way is to create a new File and copy than the table 1 into the other sheet isnt it?

 

Thanks

If my reply was helpful, please give a "Kudo" or click the "Accept as Solution" button below (or both).
0 Likes
532 Views
3 Replies
Replies (3)
Message 2 of 4

HermJan.Otterman
Advisor
Advisor

Hello Ruffy85,

 

this is from the inventor help:

 

Public Sub BOMExport()
    ' Set a reference to the assembly document.
    ' This assumes an assembly document is active.
    Dim oDoc As AssemblyDocument
    Set oDoc = ThisApplication.ActiveDocument

    ' Set a reference to the BOM
    Dim oBOM As BOM
    Set oBOM = oDoc.ComponentDefinition.BOM
    
    ' Set the structured view to 'all levels'
    oBOM.StructuredViewFirstLevelOnly = False

    ' Make sure that the structured view is enabled.
    oBOM.StructuredViewEnabled = True

    ' Set a reference to the "Structured" BOMView
    Dim oStructuredBOMView As BOMView
    Set oStructuredBOMView = oBOM.BOMViews.Item("Structured")
    
    ' Export the BOM view to an Excel file
    oStructuredBOMView.Export "C:\temp\BOM-StructuredAllLevels.xls", kMicrosoftExcelFormat
  
    ' Make sure that the parts only view is enabled.
    oBOM.PartsOnlyViewEnabled = True

    ' Set a reference to the "Parts Only" BOMView
    Dim oPartsOnlyBOMView As BOMView
    Set oPartsOnlyBOMView = oBOM.BOMViews.Item("Parts Only")

    ' Export the BOM view to an Excel file
    oPartsOnlyBOMView.Export "C:\temp\BOM-PartsOnly.xls", kMicrosoftExcelFormat
End Sub

 

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 3 of 4

MechMachineMan
Advisor
Advisor

I would play around the the Drawing's PartsList Export functionality. Seems to have a couple more options for exporting that the BOM export does.

 

If you can't get that to work, then yes, you will be stuck with manipulating excel files and moving data by interfacing with the excel API.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 4 of 4

Ruffy85
Collaborator
Collaborator

Thanks for the answers,

 

thats what i thought.

 

Anyway thx

If my reply was helpful, please give a "Kudo" or click the "Accept as Solution" button below (or both).
0 Likes