SolidWorks VBA API Events: Why Your Event Handlers Die When the Macro Stops
You set up a WithEvents handler in a SolidWorks VBA macro. The macro runs, SolidWorks does something (opens a document, rebuilds, saves), and your handler fires correctly. Then you close the macro editor and try to use SolidWorks normally — the handler no longer fires. The macro is gone, and so is your event subscription. This confuses VBA developers who are used to Office automation, where event handlers in a document’s VBA project persist as long as the document is open. SolidWorks works differently. Here’s why, and how to keep handlers alive when you need them. ...