I usually don't deal with VBA (thank goodness) - but I have been asked on several occasions to remove a VBA password from an excel workbook. In the instances that I did (remove the password) it was not for nefarious purposes, but because someone had either forgotten the password or had a file they were now responsible for and the previous user had (who set the password) had left the company.
Plus, I quite enjoyed removing passwords with this approach since it reminded me of my youth and hex-editing files (anyone remember hex-editing SimCity 2000 saves to give you lots of money??).
You'll need a hex-editor for this. Something like trusty ol' XVI32.
Make sure you have a backup of the file in case something goes wrong.
Use a hex editor to find and replace "DPB" with "DPx"
If you're trying to unlock a .xls or .xla file, open the file in your hex-editor and find for text string "DPB":
Now basically just click on the B in DPB and replace it with an "x", like this:
Save and exit your hex-editor.
Your not done yet...
Open the file in excel - you may receive a couple of error notifications, just click through them.
Open the Visual Basic window (usually ALT+F11 if I remember correctly) and open the VBAProject properties (Tools menu).
Click on the Protection tab and change (do not remove at this stage) the password to something short and easy to remember (we'll be removing in next step).
Save the workbook and then close and reopen.
Open again the Visual Basic window and enter the password you just put in. Redo the previous step but this time you can remove (delete) the password.
Save the workbook and you have now removed the password.
For xlsm files you need to do an extra step at the start. Basically xlsm is a zipped format, so rename the extension to .zip and do the following:
- open the "xl" folder
- extract "vbaProject.bin"
- do hexedit method above on the "vbaProject.bin" file
- save the file and the reinsert into the zip
- rename back to xlsm.
- repeat steps previously outlined by changing and then removing the password.