Productivity Programming Security

How to Recover an Excel VBA Password

Brad Jones 26-06-2017

Stuck with a VBA document that’s password protected? Here’s how to pick the lock.


It’s not unusual to take ownership of someone else’s Excel document Before Sharing an Excel Spreadsheet, Make Sure You Do These Things First Sharing is a convenient way to collaborate on Excel workbooks, but before you put your Excel files in the hands of others, prepare your worksheets for sharing with these tips. Read More , especially in the workplace. Usually, the transition goes smoothly — but there are pitfalls that can cause some real headaches.

For instance, six months down the line you might try edit one of the VBA macros The Excel VBA Programming Tutorial for Beginners VBA is a Microsoft Office power tool. You can use it to automate tasks with macros, set triggers, and lots more. We'll introduce you to Excel visual basic programming with a simple project. Read More that’s integral to the spreadsheet, only to find that it’s password protected. What happens now? Well, with a bit of tinkering behind the scenes, it’s not too difficult to remove that protection entirely.

Here’s how to eliminate password protection from a VBA document in Excel. It might just make you think twice about how secure your spreadsheets really are.

How to Set Up a Password

If you need to crack a password 560 Million Old Passwords Have Leaked Online It's probably time to change your passwords again. Because a huge database of 560 million login credentials has been found online, waiting to be discovered by ne'er-do-wells. Read More , you may already be aware how to set one up. However, it’s still worth laying out how this kind of protection works.

Head to the Developer tab in Excel and click Macros.


excel macros

In case you don’t see the Developer tab, go to File > Options and then Customize Ribbon. Now move the Developer command group from the left pane over to the right.

excel vba

Once you selected Macros in the Developer tab, enter a name for your macro (it’s just an example, so the specifics don’t matter) and then click Create.


protected excel macro

Copy and paste the following code into the Visual Basic Editor. This is a simple macro that will enter the quoted text into cell A1. It serves no real purpose, but we need something to protect with a password.

Range("A1").Value = "Password Protected"

You should end up with something that looks like this.

excel password code


In the Visual Basic Editor, navigate to Tools > VBAProject Properties.

vba project properties

Head to the Protection tab and you’ll be able to set a password. You’ll also need to check the box labeled Lock project for viewing.

excel password properties


Click OK, make sure to save your Excel document as an XLSM file, and we can test out whether our password works. Close your document and reopen it, then head to the Developer tab and click Visual Basic.

excel password prompt

When you try to access the relevant VBAProject, you’ll see a password prompt How to Password Protect Windows 10 Your computer is a goldmine of personal and private information. Luckily, Windows 10 has a raft of locking methods to help protect your data. Let's take a look at how you can password protect Windows... Read More . Now we can figure out how to remove this kind of protection.

How to Remove a Password

Now for the difficult part, although it’s really quite straightforward once you know what you’re doing. First, we’re going to need to download a hex editor What A Hex Editor Is & Why You Might Use It [Technology Explained] Read More . If you don’t have one already, HxD is a good free option, but there are plenty of alternatives available.

Our process differs slightly depending on whether we’re cracking a password in an older XLS file or a newer XLSM file. If you’re working with the former, feel free to skip the next section.

Preparing Our XLSM File

We need to perform a little extra preparatory work to remove a password from an XLSM file. Find it on your hard drive, then rename it, adding .zip onto the end.

Next, open it with archive compression software The Top 3 File Compression & Extraction Softwares Need to compress a large file? There's no shortage of file compression and archiving apps for Windows. But which file zipper is best for you? Here are our three top picks. Read More like WinRAR or 7-Zip. You should find a folder labelled xl.

excel xl folder

Inside this folder, you’re looking for a file with the name vbaProject.bin.

vba project properties

Extract this file and open it with your Hex Editor.

Disabling the Password

Here’s where being able to set up a password comes in handy. Create a dummy Excel document, add a macro into it, and set a password as described at the beginning of this article. Next, we’re going to take the Hex code that stipulates what the password is, and we’ll insert it into the file we want to access.

Once you have that file set up, save it and perform the same process we did a minute ago so that you end up with another vbaProject.bin file. Make sure to remember the password 4 Reasons Password Managers Aren’t Enough to Keep Your Passwords Safe Password managers are valuable in the ongoing battle against hackers, but they don't offer sufficient protection on their own. These four reasons show why password managers aren't enough to keep your passwords safe. Read More !

You should now have both of your vbaProject.bin files open in your Hex Editor. Don’t get them mixed up or we’re going to have big problems.

Use Ctrl + F in the file you created to find the following string:


This is the start of the code that stipulates the current password. We need to copy and paste three values:


Below you can see how I did it.

excel copy code

Transfer this code over to your other vbaProject.bin file, and place it in the corresponding position, making sure not to delete anything else. Save your edited hex file.

Now, delete the original vbaProject.bin file from the document we’re trying to remove the protections from. Replace it with your edited vbaProject.bin file, then change its filename back from .zip to .xlms or .xls.

Open up the file in Excel. Head to the Developer tab and click Visual Basic, and try to access the Project menu. You should see the password prompt, and with any luck, the correct password should be the one we set up in our dummy document.

excel new password

We’re back in the document! Now you can get along with whatever you were meant to be doing.

Notes on Beating the System

This trick can be very handy when you’re in a bind, and you desperately need access to a password protected VBA macro. However, it should also illustrate a major security flaw that’s present in Excel.

If you’re using this kind of password protection to defend your VBA code, know that a workaround is out there. It’s a deterrent at best — anyone with the ability to run a Google search will know exactly how to cut through your defenses.

It just goes to show how important it is for us to constantly question our security practices. Applying password protection How to Password Protect & Encrypt Your Microsoft Office Files Would you mind if someone peeked through your OneNote notebooks or had access to your Word documents? If your answer is yes, let us show you how to protect your Office files. Read More might seem to offer valuable piece of mind, but in a situation like this one, it’s not all that effective.

Do you have questions about removing password protection from an Excel document? Or do you have a security tip you want to share with others? Why not join the conversation in the comments section below?

Image Credit: OrelPhoto via

Related topics: Data Recovery, Microsoft Excel, Visual Basic Programming.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Ed
    November 27, 2019 at 1:52 pm

    I finally solved it!!!! :)
    The problem was that when I added new .bin file to archive, it did not followed the same folder structure.
    I extracted all of the "archive".
    Replaced .bin file in the right folder.
    Zipped everything back to archive.
    Changed the extension to excel.
    And voila!!! Works excellent! :)

    But it just proves how "safe are our files and everything"...
    Everything is hackable...

  2. Ed
    November 27, 2019 at 12:00 pm

    Did everything as described but end result is such that I do not see any macros at all after "breaking the password". They are gone.
    Used Notepad for editing.
    What is the reason for this? How to solve it?

    • Ed
      November 27, 2019 at 12:06 pm

      It even does not prompt for password when accessing "hacked" file...
      Why so???

  3. K A Naga Kannan
    October 21, 2019 at 9:56 am

    Oh my God!!!

    Thank you so so much...I had created a project, but unfortunately forgot the password. I thought I had to write the program again, and it will take a lot of days.
    Searched the ways to crack the password on net, but nothing helped. But really this article helped me to reset my password, and now i got access to my project.

    Really thanks again!!

  4. Mich
    September 3, 2019 at 3:02 pm

    First time i copieed everything and file size changed , and i could not open it again,
    Second time i removed all the empty or non readably characters ( and after that size was exactly the same in the password protected file) And it worked.
    What you copy should look a bit like this:

    • John
      October 10, 2019 at 8:56 pm

      Do you mind giving a bit more detail? I'm not sure what empty or non readably characters are in this.

  5. Balaji
    May 16, 2019 at 3:45 pm

    This was so awesome... I forgot the password for my own codes which I created a year back. You just saved me from hours of rewriting the codes again!

  6. Meg
    May 13, 2019 at 8:27 pm

    It's a little alarming how well this worked and how quickly I was able to get back into my file...but I'm also SO grateful this article exists and that this workaround actually did the trick. Thank you!!

  7. Daryn
    March 5, 2019 at 9:51 pm

    The code seems to notice when the size of the bin file changes causing the solution not to work. Maybe we need to do this on the same machine?

  8. Geoff
    February 9, 2019 at 10:26 am

    Tried this serveral times
    Get an error when reopening file
    VBA is corrupt and has been deleted

    • FlyingBoat
      June 6, 2019 at 7:44 pm

      I get this same error. File size changes and get the VBA corrupt message.

      • Spok
        June 26, 2019 at 9:24 am

        My filesize also changed, but I got no error. It simply worked. I would suggest to try different hex editor. (Actually I used plain text editor, not hex editor. It was sufficient.)
        Good luck!

  9. Narcisse PIKA
    May 29, 2018 at 9:19 am

    This trick worked for me perfectly !
    I'm impressed and at the same time humbled by the fact that our defence are just candy joke for someone who knows how and where to look for answers.