Protect VBA Macro with Password

Summary: The article speaks about a foolproof solution to insert password in VBA. It will help developers to keep their Macros code safe on the local machine. Taking into consideration the perspective of an investigator then, we are also providing a workaround to remove password. This will help forensic team to collect evidences from a password protected VBA file.

One or the other day, each and every individual is listening about cybercrime. Attackers are keeping a continuous eye on the information, which can easily be hacked without extra efforts. The intention of such individuals is always to harm the targeted person / group in one or the other way. Therefore, it should be in practice of computer users to keep files and folders protected. The best measure to apply protection is to impose passwords on user-created files. One such file is VBA Project, which is widely used by business owners. Now a question arises that how to add password to VBA code? In following section, checkout a stepwise process to set password in macro code.

How to Give Password to VBA Code in Excel

  • Open Visual Basic and launch project on which password is to be imposed.
  • Right click on the project and select VBAProject Properties option from the list.

VBAProject-Properties

  • A properties wizard will get open in front of you where you have to click on Protection tab.

protection-tab

  • Enable the Lock project for viewing checkbox.

lock-project-for-viewing

  • Enter desired secured text in Password and Confirm Password text box.

enter-password

  • At last, click on OK button to update the changes made in properties of VBA project.

click-on-ok

Picture this: Think of a situation where you are a forensic investigator who is provided with a password protected VBA project. This file is crucial part of your case because of which you need solution to remove password. This is now a challenging task to remove protection from a file. Therefore, a solution is illustrated below to help investigation team to remove password and collect evidences from it.

Remove VBA Password Protection

  • Install Hex Editor: You need to download Hex Editor on your machine and then install it properly on your machine.
  • Create Backup: In case you are working with an XLSM file then, save it in XLS file format. Before proceeding further, keep one thing in mind that you are having a soft copy of your workbook.

Additional Information: The guidelines to create backup file is given because few modifications are made while cracking file. These changes are deep inside file code that might reflect in existing data as well.

  • Open File in Hex Editor: Locate towards the location where VBA password protected file is located. Right-click on this file and select Open With option. Choose the Hex editor that you have installed in Step (1).

hex-editor

  • Search DPB String: In the entire Hex Editor wizard, look for a text string i.e., DPB. This will describe Excel tag for VBA Password.

search-dbp

  • Replace ‘B’ by ‘X’: Change the letter ‘B’ from DPB string to ‘X’ that will somewhat create a string like DPX.

replace-b-by-x

  • Save Your Changes: Click on Close icon of Hex Editor and click on Yes button to allow program for making the changes.

save-changes

  • Open New Project: Open the workbook with which you have recently finished molesting. Here you are going to encounter few messages:
  • In first message, click on Yes to initiate the ingoing process.

click-on-yes

  • An error statement will occur with which you do not have to get panic, instead click on OK to proceed.

upexpected-error

  • Remove Protection: Go to Visual Basic Editor by pressing Alt+F11 keys and then click on View >> Project Explorer option. Right-click on password protected of your workbook and choose VBAProject Properties from the menu.

VBAProject-Properties

  • Free up File from Password: Click on Properties tab and clear all the checkbox or text boxes that are currently flashed on your screen. Click on OK button to confirm changes.

clear-password

  • Get Unprotected VBAProject: Save and close the entire workbook. Now you are having unrestricted access to targeted VBA Project in workbook for your working.

Conclusion

Adding password in VBA project and removing it is an easy task to perform. What all one need to have is correct guidelines. The solutions provided here are first executed (delivering 100% result) and then, posted on this blog. Hope you find it reliable for your purpose!

vba-password-remover-banner-img