Yes, this is possible because the first argument for IModelDocExtension::SelectByID2 is a string. You can see this in the API Help for this API call. Run this code on the attached part and you'll see how this works:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim strSketchName As String
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
For i = 1 To 3
strSketchName = "Sketch" & i
swModel.Extension.SelectByID2 strSketchName, "SKETCH", 0, 0, 0, True, 0, Nothing, 0
I hope this helps.
sketches.SLDPRT.zip 30.3 KB
Thank you Keith for your reply but the attachement is not accessible.
I am working in SolidWorks2012.
when i try to open the attachement the pop up message comes
An error was encountered while trying to open your file. Contact technical support for possible solution.
Could you please also send the macro file also along with part file.
Thank you Keith
i edited the code as per my requirement and it worked thank you so much