Add Row to Design Table Example (VBA)
This example shows how to add a row to a design table. This operation
also adds a configuration to the part document.
'------------------------------------------
' Preconditions: Part document is open, contains a design
table,
' and
that design table is selected in
' in
the FeatureManager design tree.
'
' Postconditions: A row and configuration named 190 is
added
to the part document.
'
'-------------------------------------------
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDesignTable As SldWorks.DesignTable
Dim cells(1) As String
Dim boolstatus As Boolean
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDesignTable = swModel.GetDesignTable
' Name of configuration for newly created row
cells(0) = "190"
' Data for Column B of newly created row
cells(1) = "S"
swDesignTable.EditTable
boolstatus = swDesignTable.AddRow((cells))
boolstatus = swDesignTable.UpdateTable(SwConst.swDesignTableUpdateOptions_e.swUpdateDesignTableAll,
True)
End Sub