VBA BOM export with excel template

VBA BOM export with excel template

Anonymous
Not applicable
5,906 Views
4 Replies
Message 1 of 5

VBA BOM export with excel template

Anonymous
Not applicable

Hello,
I have found an makro and edited it so far. But now I need to save all levels of structured BOM into an excel sheet.
But the makro won't work with "all levels".
Can someone tell me why? And maybe have a solution?

 

Public Sub BOM_Export()

'generate bom test
'set variables
Dim oTemplate As String: oTemplate = "c:\BOM-Template.xlsx"
Dim oStartRow As Integer: oStartRow = 3

' set last column for array, array starts at 0 so its -1 quantity comes straight out of bom so we dont need to store it
Dim lastCol As Integer: lastCol = 9

'set individual columns for excel, use a number no letter
Dim nrCol As Long: nrCol = 1
Dim categoryCol As Long: categoryCol = 2
Dim stocknoCol As Long: stocknoCol = 3
Dim titleCol As Long:  titleCol = 4
Dim partnoCol As Long: partnoCol = 5
Dim widthCol As Long: widthCol = 6
Dim lengthCol As Long: lengthCol = 7
Dim massCol As Long: massCol = 8
Dim quantityCol As Long: quantityCol = 10

'set assembly
Dim asm As AssemblyDocument
Set asm = ThisApplication.ActiveDocument

' set reference to referenced documents
Dim rds As DocumentsEnumerator
Set rds = asm.AllReferencedDocuments

' define bom
Dim oBOM As BOM
Set oBOM = asm.ComponentDefinition.BOM

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

' set the parts only view
Dim oBOMView As BOMView
Set oBOMView = oBOM.BOMViews("Structured")

' Set the structured view to 'all levels'
oBOM.StructuredViewFirstLevelOnly = False

'set the properties we want to print
Dim oDescripProperty As Property
Dim oTitleProperty As Property
Dim oStockNoProperty As Property
Dim oCommentsProperty As Property

' store the columns in an array for easier printing
Dim oArray() As String
ReDim oArray(oBOMView.BOMRows.Count - 1, lastCol) As String

Dim a As Double: a = 0

' iterate trough bom rows
Dim oBOMrow As BOMRow
For Each oBOMrow In oBOMView.BOMRows
    
    ' setthe component definition
    Dim oCompDef As ComponentDefinition
    Set oCompDef = oBOMrow.ComponentDefinitions.Item(1)

    'Get the file property that contains the "Description"
    Set oDescripProperty = oCompDef.Document.PropertySets _
        .Item("Design Tracking Properties").Item("Description")
    
    ' set the title property
    Set oTitleProperty = oCompDef.Document.PropertySets _
    .Item("Inventor Summary Information").Item("Title")
    
    ' set the category property
    Set oCategoryProperty = oCompDef.Document.PropertySets _
    .Item("Inventor Document Summary Information").Item("Category")
    
     ' set the stock number property
    Set oStockNoProperty = oCompDef.Document.PropertySets _
    .Item("Design Tracking Properties").Item("Stock Number")
    
     ' set the part number property
    Set oPartNoProperty = oCompDef.Document.PropertySets _
    .Item("Design Tracking Properties").Item("Part Number")

     ' set the width property
    Set oPartNoProperty = oCompDef.Document.PropertySets _
    .Item("Design Tracking Properties").Item("Part Number")
    
    
    ' fill array
    oArray(a, 0) = (a + 1)
    oArray(a, 1) = oCategoryProperty.Value
    oArray(a, 2) = oStockNoProperty.Value
    oArray(a, 3) = oTitleProperty.Value
    oArray(a, 4) = oPartNoProperty.Value
    oArray(a, 9) = oBOMrow.ItemQuantity   

    a = a + 1
    
Next

' set excel app and add worksheet
Dim xlApp As Object
Dim xlwb As Object
Dim xlws As Object
Set xlApp = CreateObject("Excel.Application")
Set xlwb = xlApp.workbooks.Open(oTemplate)
'Set xlwb = xlApp.workbooks.Add
Set xlws = xlwb.Worksheets(1)
xlApp.Visible = True

' write more stuff
xlws.cells(1, 2) = asm.DisplayName
xlws.cells(1, 4) = "Nr: " & asm.PropertySets.Item(3).Item(2).Value
xlws.name = asm.PropertySets.Item(3).Item(2).Value

' print the array
Dim b As Double: b = 0

For b = 1 To oBOMView.BOMRows.Count

    ' print array
    xlws.cells(oStartRow + b, nrCol) = oArray(b - 1, 0)
    xlws.cells(oStartRow + b, categoryCol) = oArray(b - 1, 1)
    xlws.cells(oStartRow + b, stocknoCol) = oArray(b - 1, 2)
    xlws.cells(oStartRow + b, titleCol) = oArray(b - 1, 3)
    xlws.cells(oStartRow + b, partnoCol) = oArray(b - 1, 4)
    xlws.cells(oStartRow + b, quantityCol) = oArray(b - 1, 9)
Next


' save and close the document
 xlwb.SaveAs ("full string + doc name.xlsx")

' close the document
Call xlwb.Close
End Sub

This is my edit so far. Some cols missing at the moment. But think first of all the all levels export shoudl work.

0 Likes
Accepted solutions (1)
5,907 Views
4 Replies
Replies (4)
Message 2 of 5

JamieVJohnson2
Collaborator
Collaborator

BOMRow has a .ChildRows collection.  you need to check this collection for the children of the top level, and the children of those children.  This is a 'recursive' program that you must create.  Example:

 

Function DoSomethingToListWithChildren(objectWithChildren) as list(of resultingObjects)

     dim listResults as new list(of resultingObjects)

     listResults.add(objectWithChildren) 'here each object adds itself

     If objectWithChildren.Children.Count > 0 then

          for each objectChild in objectWithChildren.Children 'here each child is called to rerun this same routine (recursively)

               listResults.addrange(DoSomethingToListWithChildren(objectChild .Children))

          next

     End if

     Return listResults

End function

 

 

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 3 of 5

Sergio.D.Suárez
Mentor
Mentor

hello this is a rule that exports the list of materials to excel with a template and with thumbnails, generates the thumbnails of each reference file and then adds them as a comment, to achieve increasing the size of the view to taste without increasing the size from the list of materials. Care should be taken as to how values and file paths are entered.

If the Inv language is in English it should correct "structured" and "parts only"

I hope you understand greetings

 

 

 

Sub Main() 
On Error Resume Next 

Dim Dirtemp As String = "C:\Users\Sergio\AppData\Local\Temp\"     '''Especifique la ruta de la carpeta temporal
Dim Dirxlsx As String = "E:\Libro1.xlsx"                          ''' Especifique la ruta de la plantilla
Dim osheetbom As String = "BOM"                                   ''' Especifique la hoja de la plantilla

Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oBOM As BOM
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
    ' Make sure that the parts only view is enabled.
oBOM.PartsOnlyViewEnabled = True
    ' Establece el tipo de lista de materiales, estructurado o solo partes
	
Dim oValueList As New ArrayList
oValueList.Add("Estructurado") ''' Si el idioma de Inv esta en ingles corregir a "Structured"
oValueList.Add("Solo Piezas") ''' Si el idioma de Inv esta en ingles corregir a "Parts Only"
Dim oValue As String
	oValue = InputListBox("Selecciona el tipo de Lista a exportar", oValueList, "Estructurado", "iLogic", "Selecciones Disponibles")
	
Dim oBOMView As BOMView
oBOMView = oBOM.BOMViews.Item(oValue)
Dim orden As String = InputBox("Ordenar por", "Exportar BOM", "Part Number")

oBOMView.Sort(orden, True)' Indicar por medio de que factor se ordenara la lista
oBOMView.Renumber(1, 1)

xlApp = CreateObject("Excel.Application")

xlApp.Visible = True
xlWorkbook = xlApp.Workbooks.Open(Dirxlsx)

xlWorksheet = xlWorkbook.Worksheets.Item(osheetbom)
Dim row As Integer
row = 3                 ''' Indicar a partir de que fila comenzara el copiado a excel

'Dim bRow As bomRow
bRows = oBOMView.BOMRows
For Each bRow In bRows

Dim rDoc As Inventor.Document'Document
rDoc = bRow.ComponentDefinitions.Item(1).Document

Dim rDocName As String = rDoc.DisplayName

Dim m_Camera As Inventor.Camera
m_Camera = ThisServer.TransientObjects.CreateCamera()
If rDoc.DocumentType = kPartDocumentObject Then
  m_Camera.SceneObject = DirectCast(rDoc, PartDocument).ComponentDefinition
Else
  m_Camera.SceneObject = DirectCast(rDoc, AssemblyDocument).ComponentDefinition
End If
m_Camera.Perspective = True

Dim m_TO As Inventor.TransientObjects
m_TO = ThisApplication.TransientObjects

m_Camera.ViewOrientationType = Inventor.ViewOrientationTypeEnum.kIsoTopLeftViewOrientation
m_Camera.Fit
m_Camera.ApplyWithoutTransition
 
ThisApplication.DisplayOptions.NewWindowDisplayMode = DisplayModeEnum.kShadedWithEdgesRendering
ThisApplication.DisplayOptions.Show3DIndicator = False

Dim TumbFilename As String = Dirtemp & rDocName & ".bmp"

m_Camera.SaveAsBitmap(TumbFilename, 800, 600, m_TO.CreateColor(255,255,255))

'Next

Dim docPropertySet As PropertySet
docPropertySet = rDoc.PropertySets.Item("Design Tracking Properties")

'Se seleccionan las columnas de tabla que se exportaran al archivo excel asi como su ubicacion

xlWorksheet.Range("A" & row).Value = bRow.ItemQuantity
xlWorksheet.Range("B" & row).Value = docPropertySet.Item("Part Number").Value
xlWorksheet.Range("C" & row).Value = docPropertySet.Item("Description").Value


With xlWorksheet.Range("B" & row)
            .AddComment
            .Comment.Visible = False
			.Comment.Text(rDocName) 
            .Comment.Shape.Fill.UserPicture(TumbFilename)
            .Comment.Shape.Height = 150
            .Comment.Shape.Width = 150
End With
'xlWorksheet.Range("A" & row).Value = bRow.ItemNumber  
'xlWorksheet.Range("E" & row).Value = docPropertySet.Item("Cost").Value
'xlWorksheet.Range("F" & row).Value = docPropertySet.Item("Stock number").Value
'xlWorksheet.Range("G" & row).Value = docPropertySet.Item("Vendor").Value

row = row + 1
Next

xlWorksheet.Columns("A:Z").AutoFit

Dim oFileName As String = "Export_" &   oDoc.DisplayName & ".xlsx"
MessageBox.Show(oFileName , "Exportando a")
xlWorkBook.SaveAs(ThisDoc.Path & "\" & oFileName)' El archivo de excel se guardara en la ubicacion del archivo de ensamblaje
xlWorkbook.Close (True)
xlApp.Quit
 End Sub

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 4 of 5

Anonymous
Not applicable

OK. That's all new to me. I tried to change another macro and insert the Excel export there. But I can not stand it that I integrate a variable, which always increases the line by one. This partly overwrites the lines for me.

 

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

    Dim oTemplate As String: oTemplate = "BOM-Template.xlsx"

    FirstLevelOnly = False

    
    ' Set a reference to the BOM
    Dim oBOM As BOM
    Set oBOM = oDoc.ComponentDefinition.BOM
    
    ' Set whether first level only or all levels.
    oBOM.StructuredViewFirstLevelOnly = False
    
    ' Make sure that the structured view is enabled.
    oBOM.StructuredViewEnabled = True
    
    'Set a reference to the "Structured" BOMView
    Dim oBOMView As BOMView
    Set oBOMView = oBOM.BOMViews.Item("Strukturiert")
    
    
    Dim oPartNumProperty As String
    partNumber = oDoc.ComponentDefinition.Document.PropertySets( _
        "{32853F0F-3444-11D1-9E93-0060B03C1CA6}")("Part Number").Value
    
   
    Dim oPartRevNum As String
    oPartRevNum = oDoc.ComponentDefinition.Document.PropertySets( _
        "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}")("Revision Number").Value
        
    Dim oPartTitle As String
    oPartTitle = oDoc.ComponentDefinition.Document.PropertySets( _
        "{F29F85E0-4FF9-1068-AB91-08002B27B3D9}")("Title").Value
            
    
    ' set excel app and add worksheet
    Dim xlApp As Object
    Dim xlwb As Object
    Dim xlws As Object
    Set xlApp = CreateObject("Excel.Application")
    Set xlwb = xlApp.Workbooks.Open(oTemplate)
    'Set xlwb = xlApp.workbooks.Add
    Set xlws = xlwb.Worksheets(1)
    xlApp.Visible = True

    ' write more stuff
    xlws.Cells(1, 2) = oPartTitle
    xlws.Cells(1, 3) = oPartNumProperty
    xlws.Cells(1, 4) = "Rev: " & oPartRevNum
    xlws.name = "Stückliste " & oPartNumber
    
    Debug.Print "Item"; Tab(15); "Quantity"; Tab(30); "Part Number"; Tab(70); "Description"
    Debug.Print "----------------------------------------------------------------------------------"

    'Initialize the tab for ItemNumber
    Dim ItemTab As Long
    ItemTab = -3
    
    Dim b As Double: b = 1
    Call QueryBOMRowProperties(oBOMView.BOMRows, ItemTab, xlApp, xlwb, xlws, b)
End Sub

Private Sub QueryBOMRowProperties(oBOMRows As BOMRowsEnumerator, ItemTab As Long, ByVal xlApp As Object, ByVal xlwb As Object, ByVal xlws As Object, b As Double)
    ItemTab = ItemTab + 3
    
    Dim oStartRow As Integer: oStartRow = 3
    
    ' Iterate through the contents of the BOM Rows.
    Dim i As Long
    For i = 1 To oBOMRows.Count
        ' Get the current row.
        Dim oRow As BOMRow
        Set oRow = oBOMRows.Item(i)

        'Set a reference to the primary ComponentDefinition of the row
        Dim oCompDef As ComponentDefinition
        Set oCompDef = oRow.ComponentDefinitions.Item(1)

        Dim oPartNumProperty As Property
        Dim oPartCategory As Property
        Dim oPartTitle As Property
        Dim oPartWidth As Property
        Dim oPartHeight As Property
        Dim oPartLength As Property

        If TypeOf oCompDef Is VirtualComponentDefinition Then
            'Get the file property that contains the "Part Number"
            'The file property is obtained from the virtual component definition
            Set oPartNumProperty = oCompDef.PropertySets _
                .Item("Design Tracking Properties").Item("Part Number")

            'Get the file property that contains the "Description"
            Set oDescripProperty = oCompDef.PropertySets _
                .Item("Design Tracking Properties").Item("Description")

            b = b + 1

            Debug.Print Tab(ItemTab); oRow.ItemNumber; Tab(17); oRow.ItemQuantity; Tab(45); _
                oPartNumProperty.Value; Tab(70); oDescripProperty.Value
        Else
            'Get the file property that contains the "Part Number"
            'The file property is obtained from the parent
            'document of the associated ComponentDefinition.
                 ' write more stuff

            Set oPartNumProperty = oCompDef.Document.PropertySets _
                .Item("Design Tracking Properties").Item("Part Number")

            Set oPartTitle = oCompDef.Document.PropertySets _
                .Item("Inventor Summary Information").Item("Title")
            
            On Error Resume Next
            Set oPartWidth = oCompDef.Document.PropertySets _
                .Item("Inventor User Defined Properties").Item("Breite")
            
            On Error Resume Next
            Set oPartHeight = oCompDef.Document.PropertySets _
                .Item("Inventor User Defined Properties").Item("Höhe")
            
            On Error Resume Next
            Set oPartLength = oCompDef.Document.PropertySets _
                .Item("Inventor User Defined Properties").Item("Länge")


            'Get the file property that contains the "Description"
            Set oDescripProperty = oCompDef.Document.PropertySets _
                .Item("Design Tracking Properties").Item("Description")
                
            Set oPartCategory = oCompDef.Document.PropertySets _
                .Item("Inventor Document Summary Information").Item("Category")
                
                xlws.Cells(oStartRow + b, 1) = oRow.ItemNumber
                xlws.Cells(oStartRow + b, 2) = oPartCategory.Value
                xlws.Cells(oStartRow + b, 4) = oPartTitle.Value
                xlws.Cells(oStartRow + b, 5) = oPartNumProperty.Value
                xlws.Cells(oStartRow + b, 6) = oPartWidth.Value
                xlws.Cells(oStartRow + b, 7) = oPartHeight.Value
                xlws.Cells(oStartRow + b, 8) = oPartLength.Value
                xlws.Cells(oStartRow + b, 10) = oRow.ItemQuantity
                

            Debug.Print Tab(ItemTab); oRow.ItemNumber; Tab(17); oRow.ItemQuantity; Tab(30); _
                oPartNumProperty.Value; Tab(70); oDescripProperty.Value
            
            b = b + 1
            
            'Recursively iterate child rows if present.
            If Not oRow.ChildRows Is Nothing Then
                Call QueryBOMRowProperties(oRow.ChildRows, ItemTab, xlApp, xlwb, xlws, b + 1)
            End If
        End If
    Next
    ItemTab = ItemTab - 3
End Sub
0 Likes
Message 5 of 5

Anonymous
Not applicable
Accepted solution

Ok. Solft it. Thank you!
Some cosmetics and comments needed, but already worked for me.

 

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

    Dim oTemplate As String: oTemplate = "C:\Template.xlsx"
  
    ' Set a reference to the BOM
    Dim oBOM As BOM
    Set oBOM = oDoc.ComponentDefinition.BOM
    
    ' Set whether first level only or all levels.
    oBOM.StructuredViewFirstLevelOnly = False
    
    ' Make sure that the structured view is enabled.
    oBOM.StructuredViewEnabled = True
    
    'Set a reference to the "Structured" BOMView
    Dim oBOMView As BOMView
    Set oBOMView = oBOM.BOMViews.Item("Strukturiert")
    
    
    Dim oPartNumProperty As String
    oPartNumProperty = oDoc.ComponentDefinition.Document.PropertySets( _
        "Design Tracking Properties")("Part Number").Value
    
   
    Dim oPartRevNum As String
    oPartRevNum = oDoc.ComponentDefinition.Document.PropertySets( _
        "Inventor Summary Information")("Revision Number").Value
        
    Dim oPartTitle As String
    oPartTitle = oDoc.ComponentDefinition.Document.PropertySets( _
        "Inventor Summary Information")("Title").Value
            
    
    ' set excel app and add worksheet
    Dim xlApp As Object
    Dim xlwb As Object
    Dim xlws As Object
    Set xlApp = CreateObject("Excel.Application")
    Set xlwb = xlApp.Workbooks.Open(oTemplate)
    'Set xlwb = xlApp.workbooks.Add
    Set xlws = xlwb.Worksheets(1)
    xlApp.Visible = True

    ' write more stuff
    xlws.Cells(1, 2) = oPartTitle
    xlws.Cells(1, 3) = oPartNumProperty
    xlws.Cells(1, 4) = "Rev: " & oPartRevNum
    xlws.name = "Stückliste " & oPartNumProperty

    'Initialize the tab for ItemNumber
    Dim ItemTab As Long
    ItemTab = -3

    Dim oStartRow As Integer: oStartRow = 4
    
    Call QueryBOMRowProperties(oBOMView.BOMRows, ItemTab, xlApp, xlwb, xlws, oStartRow)
End Sub

Private Sub QueryBOMRowProperties(oBOMRows As BOMRowsEnumerator, ItemTab As Long, ByVal xlApp As Object, ByVal xlwb As Object, ByVal xlws As Object, oStartRow As Integer)
    ItemTab = ItemTab + 3
    
    ' Iterate through the contents of the BOM Rows.
    Dim i As Long
    For i = 1 To oBOMRows.Count
        ' Get the current row.
        Dim oRow As BOMRow
        Set oRow = oBOMRows.Item(i)

        'Set a reference to the primary ComponentDefinition of the row
        Dim oCompDef As ComponentDefinition
        Set oCompDef = oRow.ComponentDefinitions.Item(1)

        Dim oPartNumProperty As Property
        Dim oPartStockNumProperty As Property
        Dim oPartCategory As Property
        Dim oPartTitle As Property
        Dim oPartWidth As Property
        Dim oPartHeight As Property
        Dim oPartLength As Property

        If TypeOf oCompDef Is VirtualComponentDefinition Then
        
            Set oPartNumProperty = oCompDef.Document.PropertySets _
                .Item("Design Tracking Properties").Item("Part Number")
                
            Set oPartStockNumProperty = oCompDef.Document.PropertySets _
                .Item("Design Tracking Properties").Item("Stock Number")

            Set oPartTitle = oCompDef.Document.PropertySets _
                .Item("Inventor Summary Information").Item("Title")
            
            On Error Resume Next
            Set oPartWidth = oCompDef.Document.PropertySets _
                .Item("Inventor User Defined Properties").Item("Breite")
            
            On Error Resume Next
            Set oPartHeight = oCompDef.Document.PropertySets _
                .Item("Inventor User Defined Properties").Item("Höhe")
            
            On Error Resume Next
            Set oPartLength = oCompDef.Document.PropertySets _
                .Item("Inventor User Defined Properties").Item("Länge")


            'Get the file property that contains the "Description"
            Set oDescripProperty = oCompDef.Document.PropertySets _
                .Item("Design Tracking Properties").Item("Description")
                
            Set oPartCategory = oCompDef.Document.PropertySets _
                .Item("Inventor Document Summary Information").Item("Category")
                
                xlws.Cells(oStartRow + b, 1) = oRow.ItemNumber
                xlws.Cells(oStartRow + b, 2) = oPartCategory.Value
                xlws.Cells(oStartRow + b, 3) = oPartStockNumProperty.Value
                xlws.Cells(oStartRow + b, 4) = oPartTitle.Value
                xlws.Cells(oStartRow + b, 5) = oPartNumProperty.Value
                xlws.Cells(oStartRow + b, 6) = oPartWidth.Value
                xlws.Cells(oStartRow + b, 7) = oPartHeight.Value
                xlws.Cells(oStartRow + b, 8) = oPartLength.Value
                xlws.Cells(oStartRow + b, 9) = oCompDef.BOMQuantity.UnitQuantity
                xlws.Cells(oStartRow + b, 10) = oRow.ItemQuantity
                
        oStartRow = oStartRow + 1

        Else
            'Get the file property that contains the "Part Number"
            'The file property is obtained from the parent
            'document of the associated ComponentDefinition.
                 ' write more stuff

            Set oPartNumProperty = oCompDef.Document.PropertySets _
                .Item("Design Tracking Properties").Item("Part Number")
                
            Set oPartStockNumProperty = oCompDef.Document.PropertySets _
                .Item("Design Tracking Properties").Item("Stock Number")

            Set oPartTitle = oCompDef.Document.PropertySets _
                .Item("Inventor Summary Information").Item("Title")
            
            On Error Resume Next
            Set oPartWidth = oCompDef.Document.PropertySets _
                .Item("Inventor User Defined Properties").Item("Breite")
            
            On Error Resume Next
            Set oPartHeight = oCompDef.Document.PropertySets _
                .Item("Inventor User Defined Properties").Item("Höhe")
            
            On Error Resume Next
            Set oPartLength = oCompDef.Document.PropertySets _
                .Item("Inventor User Defined Properties").Item("Länge")

            'Get the file property that contains the "Description"
            Set oDescripProperty = oCompDef.Document.PropertySets _
                .Item("Design Tracking Properties").Item("Description")
                
            Set oPartCategory = oCompDef.Document.PropertySets _
                .Item("Inventor Document Summary Information").Item("Category")
                
                xlws.Cells(oStartRow + b, 1) = oRow.ItemNumber
                xlws.Cells(oStartRow + b, 2) = oPartCategory.Value
                xlws.Cells(oStartRow + b, 3) = oPartStockNumProperty.Value
                xlws.Cells(oStartRow + b, 4) = oPartTitle.Value
                xlws.Cells(oStartRow + b, 5) = oPartNumProperty.Value
                xlws.Cells(oStartRow + b, 6) = oPartWidth.Value
                xlws.Cells(oStartRow + b, 7) = oPartHeight.Value
                xlws.Cells(oStartRow + b, 8) = oPartLength.Value
                xlws.Cells(oStartRow + b, 9) = oCompDef.BOMQuantity.UnitQuantity
                xlws.Cells(oStartRow + b, 10) = oRow.ItemQuantity
                
              oStartRow = oStartRow + 1

            Debug.Print Tab(ItemTab); oRow.ItemNumber; Tab(17); oRow.ItemQuantity; Tab(30); _
                oPartNumProperty.Value; Tab(70); oDescripProperty.Value
            
            'Recursively iterate child rows if present.
            If Not oRow.ChildRows Is Nothing Then
                Call QueryBOMRowProperties(oRow.ChildRows, ItemTab, xlApp, xlwb, xlws, oStartRow)
            End If
        End If
    Next
    ItemTab = ItemTab - 3
End Sub
0 Likes