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

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
SOLIDWORKS VBA vs SOLIDWORKS .NET

Top reasons to upgrade your VBA macros in 2020

Converting a SOLIDWORKS VBA macro to an add-in. VBA macros continue to be the choice of the SOLIDWORKS community for…

Read Story

Delete dangling dimensions VBA macro

This macro deletes all dangling dimensions from all sheets in the active drawing document. ' Delete all dangling dimensions '…

Read Story
Arrow-up