Disclaimer: The information shared in this article is intended to show how easy it is to unlock the password protection of any SOLIDWORKS VBA macro. Please do not use this for any other reason.
Unlock any VBA macro in 5 mins
- Well, to unlock a password-protect macro, we need to start by downloading this tool: HxD, a hexadecimal binary editor. This is going to help us patch one or two entries in the .swp file.
- You probably have a password-protected VBA Macro while reading this article. If you don’t have a guinea pig, you can download this SOLIDWORKS VBA macro.
- Make sure the macro is not being used by any application (i.e. SOLIDWORKS). This will prevent HxD from making changes to it.
- Launch HxD:
- in HxD, go to File > Open and then browse to the password-protected macro’s file and click on to open it:
- Now, press Ctrl + F, and look for “DPB“. Usually, there is more than one occurrence.
- Each occurrence of “DPB“, select the letter B and change it with x.
- After replacing all occurrences of B with x in DPB, go to File and click on Save As.
- Save the macro using a different name so you do not override the original one.
- Open the macro in SOLIDWORKS by going to Tools > Macro > Edit…
- You will get this message stating that the project file contains an invalid key “DPx’ and asks you if you want to continue loading the project. Click on Yes.
- For each module in the main, the VBE will show this following dialog. Click on OK to confirm every single time.
- When the VBE editor opens, go to Tools > Properties
- Go to the Protection and change the password and click OK.
- Make sure to save the macro.
- Close and open SOLIDWORKS.
- Edit the macro again and you should be able to view the source code with your new password.
What do I need to do to protect my code?
Unfortunately, not much. Macros are pretty awesome. Their security is not. Here at Blue Byte Systems, Inc, we encourage all of our customers to consider the option of upgrading their VBA macros to add-ins. We employ the latest code obfuscation tools to make it extremely hard for anyone to reverse engineer your code. Contact us more to get a quote on how to protect SOLIDWORKS VBA macro.