Recovering Lost VBA SOLIDWORKS Macro Password

Article by GoEngineer on Nov 04, 2018

Anyone that has gotten deep enough into SOLIDWORKS automation has dabbled in macros. Most users start with VBA macros and some work their way up to VSTA macros, .NET Add-ins, or stand-alone applications.

But at some point when creating these VBA macros we decided to protect them with a password so someone else cannot get curious and break this masterpiece of coding you have created! Then a year or so down the road you need to change something and you go to edit the macro and then OOPS! What was that password? Did I write it down anywhere? So what you are left with is either starting over or just living with what you have. But that is not the case, we have a solution!

With the steps below I will show you one technique to recover your password and get those edits done.

What you will need:

  • Old password protected macro
  • New password-protected macro with known password
  • Hex editor (HxD)
  • Text editor (Notepad++)
  • SOLIDWORKS

Steps:

1. Open the new and old macro in the Hex editor.
2. Search for one of the following strings of text in the old file first
3. “CMG=”, “DPB=”, “GC=”
4. Once you find one, locate the string starting with “DPB=” and select it (Figure 1)

Figure 1: HxD interface with string selected

Figure 1: HxD interface with string selected

4. Now copy this string to your text editor (Figure 2).

Figure 2: First string pasted in text editor

Figure 2: First string pasted in text editor

5. Go back to the Hex editor and perform the same search on the macro with the known password (Figure 3).

Figure 3: HxD interface with known password string selected

Figure 3: HxD interface with known password string selected

6. Copy this string to the empty line below the first one in the text editor (Figure 4).

Figure 4: First string pasted in text editor

Figure 4: First string pasted in text editor

Note: Make sure that the string length is the same (readout in the status bar of selected text in Notepad++). If not, and the new one is shorter just add zeros to the end of the string until it is the same length.
7. Now copy the new string to make sure it is the latest in the clipboard from the text editor and then in the Hex editor highlight the string in the unknown password macro. Now right-click on that selected string and select “Paste Write” (Figure 5).

Figure 5: Using “Paste Write” in right-click to overwrite old string

Figure 5: Using “Paste Write” in right-click to overwrite old string

8. With the new string written over the old string click the Save icon in the Hex editor and close the file.
9. Finally, open SOLIDWORKS and try to edit the old macro. When you are prompted for a password enter the one from the known macro and you will now have access to edit.

If this does not work, then try replacing the string “DPB=” in both locations in the file, not just the first one. Also, there are some VBA password recovery applications that will work in this environment.

 

About GoEngineer

GoEngineer delivers software, technology and expertise that enable companies to unlock design innovation and deliver better products faster. With more than 35 years' experience and tens of thousands of customers in high tech, medical, machine design, energy and other industries, GoEngineer provides best-in-class design solutions from SOLIDWORKS CAD, Stratasys 3D printing, Creaform & Artec 3D scanning, CAMWorks, PLM, and more

View all posts by GoEngineer