Re: Removing and then adding tables in a drawing

You can get the model type from the view and then use the IF condition.

Option Explicit

Sub main()

    Dim swApp                       As SldWorks.SldWorks

    Dim swModel                     As SldWorks.ModelDoc2

    Dim swView                      As SldWorks.View

   

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swView = swModel.SelectionManager.GetSelectedObject5(1) ' Make sure a view is selected

    Debug.Print swView.ReferencedDocument.GetType ' 1 for part and 2 for assembly.

   

End Sub

Also please move this thread to API section (use move discussion on right side)

SolidworksApi macros