MACRO LIBRARY

Get text from BOM table cells

Free public access. No account or subscription required.

Files

Get text from BOM table cells

Code

Module: mMain

'Demonstrates how to get the data from the cells of a BOM table.
    
'Preconditions: Drawing is open.
'Results: See immediate window.
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim swTable As SldWorks.TableAnnotation
Dim swBomTable As SldWorks.TableAnnotation
Dim vTables As Variant
Dim i As Integer
Dim intRow As Integer, intCol As Integer
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel
    Set swView = swDraw.GetFirstView
    vTables = swView.GetTableAnnotations
    
    For i = 0 To UBound(vTables)
        Set swTable = vTables(i)
        If swTable.Type = swTableAnnotationType_e.swTableAnnotation_BillOfMaterials Then Exit For
    Next i
    
    For intCol = 0 To swTable.ColumnCount - 1
        For intRow = 0 To swTable.RowCount - 1
            Debug.Print swTable.Text(intRow, intCol)
        Next intRow
    Next intCol
End Sub