Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need to get the quantity of each component in an assembly and put that quantity into a cell in an excel spreadsheet. I attached my code below which gets the hole count for each part and puts the hole count into a cell.
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\Users\Filname.xltx")
Dim oRefDocs As DocumentsEnumerator
Set oRefDocs = oAsmDoc.AllReferencedDocuments
Dim oRefDoc As Document
For Each oRefDoc In oRefDocs
openDoc = ThisApplication.Documents.Open(oRefDoc.FullDocumentName, True)
Set oDoc = ThisApplication.ActiveDocument
'HOLE COUNT
Dim Holes As Integer
Holes = oFace.EdgeLoops.Count - 1
objExcel.cells(counter, 7).Value = Holes
counter = counter + 1
ThisApplication.ActiveDocument.Close
Next
I have tried the following code but I keep getting a type mismatch error. I also don't know how it would work.
Dim oBOM As BOM
oBOM = oAsmDoc.ComponentDefinition.BOMQuantity.GetBaseQuantity(52225)
Thank you guys for any help.
Jake Egley
Inventor 2022
Inventor 2022
Solved! Go to Solution.