"Restore Original Value" in BOM Table

I am looking for a VBA macro function or method that accomplishes the same thing as right clicking on a BOM Table cell and pressing "Restore Original Value".  I have searched the Solidworks API help, but can't find anything like it.

TIA

SolidworksApi/macros
Answers 4
FR
FR 2021-03-26 Best Answer

Hello,

You just need to set the text of the cell to "Empty".

Example for the cell on row #2 and column #2:

Option Explicit
Sub main()
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 CellRowNum As Long
Dim CellColNum As Long
CellRowNum = 1
CellColNum = 1
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swView = swDraw.GetFirstView
Set swTable = swView.GetFirstTableAnnotation
While Not swTable Is Nothing
   If swTable.Type = swTableAnnotationType_e.swTableAnnotation_BillOfMaterials Then
      swTable.Text(CellRowNum, CellColNum) = Empty
   End If
   Set swTable = swTable.GetNext
Wend
End Sub

MS
MS 2021-03-26

That Worked Great!

MS
MS 2021-03-26

That works great.  Thank you.

MS
MS 2021-03-26

Thank you, I'll give it a shot!