This is a reported issue/bug (BR10000387004), and fixed in SW2024 SP4 with Hotfix. You may contact your VAR, and they would help with the required hotfix.
Check if "Update component names when documents are replaced" is selected under Tools > Options> External References. If not, then select it, and try again.
I tested your codes, and they worked OK for me. So something not correct with your workflow. Can you check the macro references, remove any references that says utilities, and then try again?
The only change I made was to hard code the path, since you had not shared the codes for the browse...
Matt has decided to take down all his site!!
We are trying to get them back running (still working on how to execute it) as Matt has agreed to help/share the files of the sites.
swComp.Name2 gives component name followed by it's instance id. So in your case, if a component is used more than once (for e.g. pattern components), the codes may give error. So you may need to do 2 things:
1. Get a unique list of the components (parts) you want to rename.
2. Use file part...
What is your end goal to select the parts?
You can use IAssemblyDoc.GetComponents wtih False option to get all the assembly component. Then you can get the modeldoc for each component, get the model type, and select only the parts.
You can use the edrawings control (it may be slow) OR can capture image of the selected components, save in the temp location and show in the image box.
Try following codes. Add more hole cases as needed.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim HoleFeatData As SldWorks.WizardHoleFeatureData2
Sub Main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc...