Selecting a File via UserForm VBA Solidworks

Hello

I'm brand new on the forum, but after looking for a while I don't think I've seen any questions and even less answers that would allow me to solve my problem.

I want to add a PART to an assembly and through a UserForm and constrain it (so that the two origins are coinciding).

Through the form I identify the name of my new assembly and the folder in which it is saved and I would therefore like to create a "CommandButton" allowing me to select my PART. To identify the registration folder I managed to open the explorer, but I only have access to the folders and this time I would like to select a specific file.

Thank you in advance for your help.

1 Like

Hello

Look at this thread: http://www.lynkoa.com/forum/solidworks/bouton-parcourir-macro-vba

1 Like

There's a macro here http://www.cadsharp.com/videos/lesson-5-1-vba/

but you have to be a paying subscriber

and that's not my case

You are here: Home » Videos » Lesson 5.1 - Creating a New Assembly

This content requires a higher-level membership. 

In this lesson, you'll learn how to fully automate the creation of a set, with a particular focus on mating techniques.

An alternative to mating with named entities is to use constraint references, as with mate entities, which requires your designers to include constraint references beforehand to facilitate simpler automation. See IMateReference interface for more information. In my opinion, however, automating using constraint references is much more tedious than automating with named entities.

If for some reason named entities aren't an option, but you don't want to go the tedious mate route references, you can also create reference geometry like planes and axes to use with coupling. Using IModelDocExtension:: selectByID2 you can easily select the reference geometry.

Lesson 5.1 Getting Started Code 
Lesson 5.1 - Drawer 
Lesson 5.1 - Crank

2 Likes