You may think it’s easy – just open VB Editor (ALT + F11), go to Tools > VBAProject Properties…, switch to Protection tab, check Lock project for viewing, set a password, hit OK and save your file. But is your code really safe now? No, it’s not. There are several methods or third-party software that can crack this protection in seconds. I have described two of them on my blog – here and here.
So is there a way to lock your VBA project for good? Yes, there is. For example Unviewable+ or Secure++ – both created by Petros Chatzipantazis from Spreadsheet1.com. How do they work? Usually when you try to expend protected VBA project you will be prompted for a password.
If you can see above window it means the file can be cracked. Using mentioned software you can make your project unviewable. Then, trying to expend VBA project, you should see below message.
This operation is irreversible so keeping the editable copy of your file is recommended! Now there is no way to crack VBA project and see what’s inside.
But software offered by Petros is quite expensive – you need to pay $100 for a single developer license. But you can have the same effect for free. How? Just follow the steps described below.
You will need two freeware programs:
Download and install both of them. Now make a copy of the Excel file you want to make unviewable (remember – once you do it there is no way back!) and change it’s extension to .zip. Right-click on the archive and go to Open with > WinRAR archiver – you should see below window.
Now double-click on xl folder and extract vbaProject.bin file. To do this you can either select the file and hit Extract To button or simply drag & drop the file onto your Desktop. Once you have it extracted, right-click on the file, go to Open with > Choose default program… – new window should appear. Hit Browse… – now navigate to the directory where Notepad++ is installed (“C:/Program Files (x86)/Notepad++/” in my case), choose notepad++.exe and hit Open.
If you want to make Notepad++ a default program for all *.bin files check Always use the selected program to open this kind of file. Then hit OK.
vbaProject.bin file should now open in Notepad++. It will look somewhat like this.
Now scroll down until you find the section with CMG=, DPB= and GC=.
For Excel workbook files (tested on .xlsb) you can replace the CMG, DPB and GC strings between parenthesis with any even number of “F”s greater than or equal to the number of characters in the original strings and for Add-in files (tested on .xlam) you need to replace them with the exact same number of “F”s as the number of characters in the original strings.
Now Save the changes (CTRL + S), close Notepad++ and drag & drop the file back in the archive to replace the original with the updated one. When new window appears just hit OK.
You can be sure that the file was updated when it’s Modified date is changed.
Now you can close WinRAR and change the extension from .zip back to original Excel file extension (.xlsb, .xlam, etc.). Now when you open the file, go to VB Editor and try to expand the VBA project. Instead of password prompt you should see a message saying that the Project is unviewable.
You project is now uncrackable. No one (even you) can see or edit the VBA code.
Hope that helps!