Circumventing Excel VBA Password Protection

 

VBA Password Prompt

VBA Password Prompt

It happens to everyone at some point. You cleverly password-protected your work so no one would change it, but now it’s three years later and you’ve forgotten the password. Let’s see how we can easily solve this problem in the case of a password-protected VBA Project. You open up your *.xlsm file and press Ctrl+F11 to bring up the VBA window. You select the VBA project and instead of seeing the modules and their code, you see this heartless prompt.

You are, of course, despondent. What were you thinking? What password were you using for this sort of thing three years ago? Don’t remember? Don’t fear! You can still get your code back by following these steps.

First, save a copy of your file in the pre-Office-2007 format as Excel 97-2003 Workbook (*.xls). You may, of course, skip this step if your file is already of the correct format.

Excel 97-2003 File Type

Excel 97-2003 File Type

Next, close Excel and open up this *.xls file in your favourite hex editor. Use your hex editor’s search function to find the ASCII string “DPB=”. Change this string to something else like “DPx=” and save your changes.

xls file in hex editor   xls file in hex editor updated

Now, open up the file in Excel again . You will receive an error message like this:

Excel Key Change Error Message

Excel Key Change Error Message

Select ‘yes’ and open up the VBA Editor. You will get another error message that you can just ignore.

Cryptic Error Message

Now, right click on VBAProject and select properties.

 

On the protection tab, type in a new password and click OK. Now you can go ahead and open up your modules and see what wondrous code is in there!

    

 

Download the sample file and try it yourself : Example