In this Article
Protect VBA Code
When you write code in VBA to customise your Microsoft Office application, you might end up distributing that code to clients or colleagues. If you do this, you may want to protect your code so that it can not be copied by other users. You can protect your code by adding a password to the entire VBA Project. This will ensure that no one can view the modules and forms in your VBA Project.
Add Password to VBA Project
- Select the Project you wish to protect in the Project Explorer.
2. Right-click on the Project Name, and then click on Properties in the shortcut menu.
- Click on the Tools menu, and click on the Properties
- Click on the Protection tab
- Check the “Lock project for viewing” tick box, and then type in the password you wish to use to lock the project.
6. Re-type the password in the Confirm Password box, and click OK.
7. Save your file.
8. Close your File, and then re-Open it again.
9. Press F11 to go to the VBE.
10. You will notice that you cannot see any of the forms or modules
11. Click on the plus-sign to the left of your project name.
12. Type in your password to enable you to view your modules and forms.
Remove Password Protection from VBA Project
- Right-click on your VBA Project and select the project Properties, or go to the Tools menu and select the Properties option.
- Select the Protection tab, and un-check the “Lock project for viewing” check box.
- Click OK.
4. Remove your password from the Password and Confirm password
TIP: if you do not remove the password, the Project will be unlocked and the modules and code will be able to be viewed, but you will still need the password to go into the project properties.
- Save your file.
VBA Coding Made EasyStop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!