I received a great question from one of my newer customers the other day: “Why can’t I ever seem to get an API Help example to work right after copying and pasting it into the Visual Basic Editor?” The answer, simply, is that the text is rarely transferred over perfectly. As demonstrated in the tutorial below, cleanup is involved. I also take it a step further and show you some tips for improving the readability of the code. Finally, I explain how to deal with errors that occur when trying to run the macro from Tools–>Macro–>Run.

For those of you who like to remove every last unnecessary line of code: you can also remove the enumeration declarations in the beginning. They exist in many API Help examples but they really serve no purpose since by default the SolidWorks constants type library is automatically referenced.

Thanks for visiting our blog and merry Christmas!

Keith

Want to keep up with future CADSharp.com content, webinars, and special offers? Sign up for our newsletter.