MACRO LIBRARY

Get cell data in active sheet's table

Free public access. No account or subscription required.

Files

Get cell data in active sheet's table

Code

'Preconditions: drawing sheet is active with BOM table
'Results: BOM table contents is printed to 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 i As Integer
Dim j As Integer
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel
    Set swView = swDraw.GetFirstView
    Set swTable = swView.GetFirstTableAnnotation
    Do While Not swTable Is Nothing
        If swTable.Type = 2 Then
            For i = 0 To swTable.ColumnCount - 1
                For j = 0 To swTable.RowCount - 1
                    Debug.Print "Column " & i & ", Row " & j & ": " & swTable.Text(j, i)
                Next j
            Next i
        End If
        Set swTable = swTable.GetNext
    Loop
End Sub