How to remove a password in a MS Excel VBA project?
Years ago I automated some work in MS Excel with VBA. Sometimes I decided to protect the source code with a password. A password that later turns out not to provide sufficient protection for the file because the password can be removed. This was very nice for me, because I wanted to see the source code of a script I had made years ago. I did not remember the associated password. The password on the MS Excel file to protect the source code was created by me so long ago that I could no longer remember it. And no, at the time I wasn’t worried about ever wanting to look at the source code again. But through a training I was reminded that I had created something years ago and now I wanted to see the source code, but I couldn’t access it because of the password. This post is purely for educational purposes and should not be misused.
A password is not needed, we can remove it!
The password that protects a VBA source code in MS Excel can be removed in a number of steps. In the steps below I will share with you how you can remove the password from your password-protected file. The steps below are tested in MS Excel 2019.
- If you don’t have yet 7-Zip and Notepad++ download them and install both applications. They are free to use.
- Open Explorer and navigate to the MS Excel file with the VBA code in it.
- Now we should press the right-click with the mouse on the xlsm file and choose
7-Zip
–>Open archive
. - We have to open the
xl
folder. - Next we should drag the file
vbaProject.bin
from the 7-Zip environment (for example to your desktop). A copy is then made. - Right-click with the mouse on the
vbaProject.bin
file and chooseEdit with Notepad++
. - We should now search for
DPB
and replace it withDPx
. - Now you can save the file (this can be done with
CTRL + S
). - Drag the
vbaProject.bin
file back into the 7-Zip folder and overwrite the original file. - Open the Excel file. You will now receive a message that an invalid key has been found. Choose to continue loading.
- You will now receive an
unexpected error, message 40230
. ClickOK
. - Save your Excel file again.
- Now the password for your VBA project is gone and you can view the project and the macro again.