Protect macros with a password – Valid for Excel and SOLIDWORKS

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.

Found an error or have suggestions? Send corrections via the comment section below. 👇

📝 Subscribe Now and join our community for goodies and more!