Well, I cut-and-pasted right out of the SW API help. It may take a bit to get used to SW's help syntax. Remember that the VB command is the "OLE" and not the "COM".
Pay attention to return value data types. Don't use variants unless specifically called for. For that matter, always use the specific data type that is called for (boolean, long, etc.)
Early binding of objects (are you still with me?) helps loads. Whenever possible, define objects specifically, i.e. use
Dim swApp as SldWorks.SldWorks rather than
Dim swApp as Object. That way, the available properties and methods come up as soon as you type that dot after the object. Also, have you discovered the joys of
ctrl-J in the VB editing environment, yet?
The only hitch with early binding and SW API is with file SW objects. SW models are really two objects, i.e. a part is a
PartDoc and a
ModelDoc, which means that you do need to "Dim" them as
Object. One alternative: I have recently started wrapping SW docs in a class object that gives access to early binding for all of the subobjects. If you are interested, I will post it to my website.
There are two types of people in the world: the kind that believe that people can be categorized into one of two groups and the kind that don't.