Why Word VBA Project Locked Despite the Password Being Correct
🔍 WiseChecker

Why Word VBA Project Locked Despite the Password Being Correct

You enter the correct password for a VBA project in Word, but the project remains locked and you cannot view or edit the macros. This happens because the VBA project protection in Word has two layers: a password for viewing the project and a separate lock that persists even after the password is accepted. This article explains why the VBA project stays locked, how to unlock it using the correct method, and what to do if the project remains inaccessible.

Key Takeaways: Unlocking a VBA Project in Word

  • VBA Project Properties > Protection tab > Lock project for viewing: This setting must be unchecked to fully unlock the VBA project after entering the correct password.
  • Alt + F11 to open the VBA editor: Use this shortcut to access the VBA project and check the lock status.
  • File > Options > Trust Center > Trust Center Settings > Macro Settings: Enable all macros temporarily if macros are disabled, which can prevent the VBA project from being unlocked.

ADVERTISEMENT

Why the VBA Project Stays Locked After Entering the Correct Password

Word protects VBA projects with a two-stage mechanism. The first stage is password authentication: when you try to expand the project tree in the VBA editor, Word prompts you for the password. If the password is correct, the tree expands and you can see the project modules. However, the second stage is the “Lock project for viewing” checkbox in the VBA Project Properties. Even after you enter the password, if this checkbox remains checked, the project contents stay locked. You cannot view, edit, or export the code.

This design is intentional. The password grants access to the project structure, but the lock prevents any modification or viewing of the actual code. To fully unlock the project, you must uncheck the lock option while the project is unprotected. If the lock was applied by a previous user or a template, you need to remove it manually.

How the Lock Setting Works

The lock setting is stored in the VBA project file itself. When you open a document that has a locked VBA project, Word reads the lock flag and applies the restriction regardless of whether you have the password. The password is only needed to change the lock setting. If you have the password but the lock is still active, it means the lock was not removed during a previous session or the document was saved with the lock enabled.

Steps to Unlock a VBA Project in Word

Follow these steps to unlock the VBA project after entering the correct password. These steps work in Word 2016, Word 2019, Word 2021, and Microsoft 365.

  1. Open the VBA editor
    Press Alt + F11 on your keyboard. The VBA editor window opens. If the project is locked, you will see a lock icon next to the project name in the Project Explorer pane.
  2. Enter the password
    Right-click the locked project name in Project Explorer and select VBAProject Properties. Go to the Protection tab. In the Password field, type the correct password. Click OK. The project tree now expands, showing modules and forms.
  3. Uncheck the lock option
    Right-click the project name again and select VBAProject Properties. Go to the Protection tab. Uncheck the box labeled “Lock project for viewing.” Leave the Password and Confirm password fields blank. Click OK.
  4. Save the document
    In the VBA editor, click File > Save [document name]. Alternatively, switch back to Word and press Ctrl + S. This saves the change that removes the lock.
  5. Close and reopen the document
    Close the document completely. Reopen it in Word. Press Alt + F11 to verify that the VBA project is now unlocked and you can view and edit the code without a password prompt.

If the Lock Option Is Grayed Out

If the “Lock project for viewing” checkbox is grayed out, you cannot change it because the project is currently locked. In this case, you must first enter the password as described in step 2. After the password is accepted, the checkbox becomes editable. If it remains grayed out, the document may be protected by other restrictions, such as a digital signature or Information Rights Management.

ADVERTISEMENT

If the VBA Project Still Stays Locked

Word Macros Are Disabled

Word may block macros entirely if the Trust Center settings are too restrictive. When macros are disabled, the VBA editor may not allow you to modify the project lock. To check this, go to File > Options > Trust Center > Trust Center Settings > Macro Settings. Select “Enable all macros” temporarily. After making the change, repeat the unlock steps. Remember to revert to a safer setting after you finish.

The Document Is Read-Only or Protected

If the document is marked as final or is opened in Protected View, you cannot modify the VBA project. Click the Edit Anyway or Enable Editing button in the yellow bar at the top of the document. If the document is stored on a network share with read-only permissions, copy it to your local drive first.

Password Is Correct But the Project Does Not Expand

This indicates that the password was set for a different layer, such as the document open password or the modify password. The VBA project password is separate. Check the document protection settings: go to File > Info > Protect Document. If the document has a password to open, you must enter that first. The VBA project password only controls access to the macro code.

VBA Project Lock Status: Before and After Unlocking

Item Locked State Unlocked State
Project icon in Project Explorer Shows a small lock overlay No lock icon
Ability to expand project tree Requires password; after password, tree expands but code is hidden Tree expands without password; code is visible
Lock project for viewing checkbox Checked and grayed out Unchecked and editable
Ability to edit or export macros Not possible Possible
Password prompt on next open Appears every time Does not appear

You can now unlock any VBA project in Word as long as you have the correct password. Always uncheck the lock option and save the document to make the change permanent. For documents you receive from others, check the Trust Center macro settings first to ensure macros are enabled. If you frequently work with locked VBA projects, consider creating a macro that automates the unlock process by clearing the lock flag programmatically.

ADVERTISEMENT