Blog 12.17.2012 2 Comments

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!


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


  1. ChrisDanger

    I find a neat way to delete the blank lines is to first paste into MS Word, Remove Space Before Paragraph and Remove Space After Paragraph in the Line and Paragraph Spacing pull-down in the Paragraph block on the Home Tab, then paste into the VB editor.

Questions and Comments

You must be logged in to post a comment.