2 Replies Latest reply on Sep 7, 2015 10:50 AM by Arvind Purushotaman

    Printing out the name of the selected part

    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.