Skip to content

Why Don’t My Macros Work in SOLIDWORKS?

Article by Scott Durksen, CSWE created/updated August 21, 2013

Starting in SOLIDWORKS 2013, a new version of Microsoft Visual Basic for Applications was introduced.  SOLIDWORKS now uses VBA 7.1 rather than VBA 6.  This new VBA version supports 64-bit systems.  As a result, your old SOLIDWORKS macros broken as they may not compile correctly with this change.

SOLIDWORKS Macros Broken

SOLIDWORKS Macros Broken

One example is Declare statements used in prior versions of SOLIDWORKS.  These Declare statements must now be marked as safe using the “PtrSafe” attribute on 64-bit systems.

Also the “Long” variable for function arguments representing pointers will require the use of the “LongPtr” variable instead.

Please refer to the following Microsoft web page for more information.

If you are using Win32 APIs, this new version also requires a change to the way you import these APIs.  Rather than making multiple versions of macros, you can use conditional compiler directives (#If Then, #Else, #End If).  This will allow the macro to work in SOLIDWORKS 2012 or 2013 in either 32-bit or 64-bit environments.  For more details and examples, please see the following forum posts.  An active SOLIDWORKS Subscription and Customer Portal account is required:

Posts related to 'Why Don’t My Macros Work in SOLIDWORKS?'

Find Related Content by TAG:

Scott Durksen, CSWE

Scott is a SOLIDWORKS Elite Applications Engineer and is based in our Dartmouth, Nova Scotia office.

Want to learn SOLIDWORKS?

Take a training course from our team of Certified SOLIDWORKS Experts

Scroll To Top