Protect macros with a password – Valid for Excel and SOLIDWORKS

Amen Jlili

TLDR:


This content of this article is applicable to both SOLIDWORKS and Microsoft Office Excel, PowerPoint and Word.


Protecting macros with a password will prevent users from viewing the source code. You might want to go the extra mile to protect your macro’s from viewing for many reasons. For example you want to:

  • Protect the macro modules from being inadvertently edited by inexperienced users.
  • Lock the macro from viewing to avoid code exceptions being thrown.
  • Protect your intellectual property above all.


This short article will show you how to lock a VBA macro from being viewed, with a password. Users will continue to be able to run the macro but will not able to view the content of the macro’s modules. These steps are very straight-forward:

  • In the VBE Editor go to Tools > Macro_Name Properties. If the macro is already protected with a password, this option might be greyed out.
  • In the protection tab :
  • Check lock project for viewing.
  • Add a password and then confirm it.
  • Save the macro to apply changes after that.
Protect Macro - Project properties window
Protect Macros – Project properties window

Is my macro protected 100% of the time ?

Unfortunately, protecting a macro with a password does not provide you with the ultimate security. For example, check this article on how to crack any password-protected VBA macro.


What to do to protect my code?

To conclude, the best thing to do is to upgrade your macro to SOLIDWORKS add-ins. In addition to our PDM implementation services, Blue Byte Systems, Inc. has a great wealth of experience upgrading old legacy VBA code to powerful .net Add-ins. Contact us or schedule a quick zoom call here.

0 Comments

Leave a Reply

More great articles

Delete all properties for the active configuration – SOLIDWORKS MACRO

The following macro deletes all the properties from the active configuration. The macro is written used late-binding so it is…

Read Story

Export Bill Of Materials to Excel with thumbnails

This macro exports Bill of Materials to Excel with thumbnails. You definitely need this one if you are on SOLIDWORKS 2018…

Read Story
VBA LOGO

Early binding vs Late Binding: How to write macros that will always run with no errors

TLDR: Here's what you need to know about Early Binding Vs Late Binding Use early binding for writing macros. It…

Read Story
Arrow-up