Unfortunately i don’t understand this code (from your link) after some hours of considerations.
I use the code from this topic with some changes.
- I use the Structured BOM for catch info about sub-assemblies in the assembly.
- I write data to Excel at Debug section.
See these steps:
…
…
' Debug.Print oBOMRow.ItemNumber; " "; oPartNumProperty.Value; " Qty="; _
' Qty; " "; oDescripProperty.Value
' write parts data to Excel
GoExcel.CellValue("B" & RowNum) = "+"
GoExcel.CellValue("C" & RowNum) = oPartNumProperty.Value
GoExcel.CellValue("D" & RowNum) = oDescripProperty.Value
GoExcel.CellValue("E" & RowNum) = Qty
RowNum = RowNum + 1
If TypeOf oCompDef Is AssemblyComponentDefinition Then
RowNum = RowNum + 1
ComponentNum = oPartNumProperty.Value
' MsgBox ("A Sub-assembly found " & ComponentNum )
End If
End If
Next
…
…
This code work very well, and produces output like on picture.
Excel spreadsheet has same name as the main assembly.
You can see that the code perform check of the current component and register if it is a assembly.
After the line with MsgBox shall be a jump to sub- code that write data about the sub-assembly components to the spreadsheet. (I think). What if the sub-assembly contains a sub-sub-assembly?
The Sub-code should jump in such case to itself with “start data” about this sub-sub-assembly. And so on.
First after no assembly in sub code the sub-code should return to the main code.