Protect Visual Basic for Applications code with a password

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.

  1. Open the Microsoft Access project or Microsoft Access database with the VBA code you want to protect.

  2. In the Database window, on the Tools menu, click Macro, and then click Visual Basic Editor.

    Tip   You can also press ALT+F11.

  3. In the Microsoft Visual Basic Editor, on the Tools menu, click <Access database or Access project name> Project Properties.

  4. Click Protection.

  5. Select the Lock project for viewing check box.

  6. 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