Run VBA and VSTA macros in SOLIDWORKS

Edit ArticleEdit Article

The simplest way to run the macro is to call it from the Tools->Macro->Run menu command or toolbar.

Running macro from menu
Running macro from menu

Select the macro to run (either .swb or .swp for VBA macro or .dll for VSTA macro). Unless macro explicitly coded to stay active or Stop VSTA debugger on macro exit option in Settings is checked for VSTA macro, macro is unloaded from the memory once he execution is finished.

Macro can be also run directly from the VBA Editor when opened for editing either from the menu/toolbar or using F10 shortcut.

Running macro from VBA Editor
Running macro from VBA Editor

Alternatively, macro can be run from the macro button or command line when SOLIDWORKS session starts


All articles and code at CodeStack are now open-source and hosted on GitHub. If you want to contribute by modifying existing articles and code snippets, submitting new ones, reporting errors and bugs etc. please follow this blog post for more information. We appreciate any contribution.

Product of Xarial Product of Xarial