SOLIDWORKS macro is the most common way to automate and extended the functionality of SOLIDWORKS via its API. Macros can be developed in-house or downloaded from the different web-sites including SOLIDWORKS forum, 3D Content Central, Code Stack etc. or even recorded from SOLIDWORKS.

But in some cases the macro doesn’t work as expected. This is usually one of the following scenarios:

  • Macro which used to work correctly before stopped working.
  • Macro works on some of the workstations but not on the others.
  • Macro works correctly for some models but not the others.

In this article I will go through the most common symptoms of the errors in the macros. Click link to get the detailed description of the issues, its cause and the steps to resolve the problem.

Fixing the Cannot Open error when running the VSTA macro (C# or VB.NET)

Fixing the Run-time Error '91' or Run-time error '13' when running the macro

Fixing the error in the macro which connects to database (e.g. SQL, MySql, Oracle, MS Access etc.) or any other data source and doesn't read/write values or displays error

Fixing the Run-time Error '5' - Invalid procedure call or argument error when running a macro which is using the title of the model (e.g. inserting the note, linking the custom property value, generating new file name for exporting)

Fixing the Compile error - Invalid outside procedure error when placing the long text into the VBA macro variable

Fixing the error when selections in the macro are not consistent

Fixing the inconsistency of sketch segments (line, arcs, etc) or sketch points creation in the macro

Fixing Run-time error '424' - Object required for macros which work correctly independently but failed to work when merged to one

Fixing the compile error of VSTA macro when the code is copied from the example

Fixing the Cannot Open error when opening or running the macro stored under the long projects structure

Fixing the error when running or editing the legacy macro in swb format

Fixing the Run-time Error '91' - Object variable or With block variable not set when macro is working with the components in the assembly

Fixing the macro which fails when run on old (not the latest) version of SOLIDWORKS and Run-time error '438' - object doesn't support this property or method or Run-time error '445' - object doesn't support this action error is displayed

Fixing the Compile error - The code in this project must be updated for use on 64-bit systems when macro is utilizing Windows API functions

Fixing Can't find project or library error in legacy macro

Fixing the macro which doesn't work if it is run from the Tools->Macro->Run menu in SOLIDWORKS but works correctly if opened in the VBA editor and executed via F5 or by clicking green arrow