Works fine for me. Make sure you've a component selected OR add the condition to check that a component has been selected
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
MsgBox "Name: " & swModel.SelectionManager.GetSelectedObjectsComponent4(1, -1).Name2
Thank you Deepak.
Works fine now.