Protect Visual Basic for Applications code with a password
To prevent someone from viewing or making undesired changes to your Visual Basic for Applications (VBA) code, you can protect VBA code by requiring a password.
- Open the Microsoft Access project or Microsoft Access database with the VBA code you want to protect.
- In the Database window, on the Tools menu, click Macro, and then click Visual Basic Editor.
Tip You can also press ALT+F11.
- In the Microsoft Visual Basic Editor, on the Tools menu, click <Access database or Access project name> Project Properties.
- Click Protection.
- Select the Lock project for viewing check box.
- Enter a password in the Password box, and confirm the password by entering it again in the Confirm password box.
The next time you open the Access database or Access project, the VBA code will be protected by requiring you or any user to enter the password defined in step 6 to view and edit the VBA code.
Notes
- To remove the password, clear all information in the Protection tab of the <Access database or Access project name> Project Properties dialog box.
- If you set a password but don't select Lock project for viewing, the code can be viewed and edited by anyone, but the Project Properties dialog box is protected.
- Don't forget the password. If you forget the password, you will not be able to view or edit the VBA code.