AnsweredAssumed Answered

Printing out the name of the selected part

Question asked by Arvind Purushotaman on Sep 7, 2015
Latest reply on Sep 7, 2015 by Arvind Purushotaman

Hello guys,


I am trying to get a message box that shows the name of the selected component in an assembly. I used the following snippet. I am getting an error


Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swsel As SldWorks.SelectionMgr

Dim component As Component2



Sub main()


    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc


    Set swsel = swModel.SelectionManager

    Set component = swsel.GetSelectedObjectsComponent4(1, -1)

    MsgBox "Name: " & component.Name2                                    


End Sub


It shows some issue in the line   "MsgBox "Name: " & component.Name2".


Can someone please help me out.