Can someone teach me the basics of VBA in solidworks?

Hello all,

I am far from any kind of programmer but I have been trying to learn VBA programing for the past year now with both excel and solidworks.  It seems to be near impossible to find any clear explanation on the basic structure and concepts of VBA programming. I can usually copy/paste bits of code together to make a complete macro, but they are very sloppy and I don't fully understand exactly what the individual parts of the code are doing.  I have tried searching the web, gone through much of the solidworks API help etc but I feel like I don't even understand enough to make sense of the API help.

Basically what I am looking for is some basics and if possible an explanation of these specific things:

  • vocab and terminology.  Specifically things like:
    • dim vs set
    • Boolean???
    • etc.
  • The hierarchy.  Specifically:

    • .sldworks vs .solidworks????
    • modeldoc2
    • application.sldworks vs sldworks.application

  • selection manager.  Specifically:
    • component2
    • GetSelectedObjectTyp(2, 3)    vs    .GetSelectedObject (2-6)

It is just all very confusing and I cant seem to make sense of it.  If anyone would like to take the time to teach me over the forum/PM or point me in the direction of some good resources to start learning VBA I would really appreciate it.  Simple examples would be great too!

Thanks!

Evan

SolidworksApi macros