Word Error: Compile Error in Hidden Module — VBA Fix
🔍 WiseChecker

Word Error: Compile Error in Hidden Module — VBA Fix

When opening a Word document that contains macros, you may see a message that says “Compile error in hidden module.” This error prevents the document from loading properly or stops macros from running. It occurs because Word cannot compile the Visual Basic for Applications code stored in a hidden module within the document or template. This article explains what causes this error and provides step-by-step methods to fix it, including how to safely disable or repair the problematic VBA code.

Key Takeaways: Fixing the Compile Error in Hidden Module in Word

  • Developer > Visual Basic > Tools > References: Remove broken or missing library references that cause compile errors in hidden modules.
  • Developer > Macros > Normal.dotm Organizer > Delete hidden modules: Remove corrupted VBA modules from the Normal template to stop the error on all documents.
  • File > Options > Trust Center > Trust Center Settings > Macro Settings > Disable all macros with notification: Temporarily block macros to open the document without the compile error.

Why Word Shows a Compile Error in a Hidden Module

The compile error in a hidden module occurs when Word tries to load VBA code but cannot verify or compile it. The hidden module is a part of the document or template that contains macro code but is not visible in the normal document view. Word hides these modules intentionally to protect the code from casual users. However, if the VBA code references a library or object that is missing or incompatible on your system, Word fails to compile the code and shows the error.

Common triggers include moving a document from one version of Office to another, copying macros from an older 32-bit system to a 64-bit system, or opening a document that uses a COM add-in not installed on your computer. The error message often includes a reference to a specific module name, such as “Module1” or “ThisDocument,” but the module itself remains hidden from the user interface.

The Role of the Normal.dotm Template

The Normal.dotm template is the default global template in Word. It stores macros and VBA code that apply to all documents. If the Normal.dotm template contains a hidden module with a compile error, every document you open in Word will trigger the error. This makes the problem system-wide rather than limited to one file. Checking and repairing the Normal template is often the fastest way to resolve the issue.

Steps to Fix the Compile Error in Hidden Module

The following methods address the most common causes of the compile error. Start with Method 1 because it resolves the majority of cases. If the error persists, proceed through the remaining methods in order.

Method 1: Remove Broken Library References

  1. Open the Visual Basic Editor
    Press Alt+F11 on your keyboard to open the VBA editor. If the document opens with the error, you may still access the editor.
  2. Open the References dialog
    In the VBA editor, click Tools on the menu bar, then click References. This shows all library references the project uses.
  3. Identify missing references
    Look for any entry that says “MISSING:” at the beginning. These references point to libraries not installed on your system. Uncheck the box next to each missing reference.
  4. Confirm and close
    Click OK to close the References dialog. Then close the VBA editor. Save the document and reopen it to test if the error is gone.

Method 2: Delete the Hidden Module from the Normal Template

  1. Close all open Word documents
    Ensure no documents are open. The Normal template loads when Word starts with no documents.
  2. Open the Organizer
    In Word, go to the Developer tab and click Document Template. If the Developer tab is not visible, right-click the ribbon, select Customize the Ribbon, and enable the Developer tab. Then click Organizer.
  3. Switch to the Macro Project Items tab
    In the Organizer dialog, click the Macro Project Items tab. On the left side, you see the Normal.dotm template. On the right side, you see the current document.
  4. Remove the hidden module from Normal.dotm
    In the left panel, select the module that contains the error. The name may be Module1, NewMacros, or a custom name. Click Delete. Confirm the deletion when prompted.
  5. Close the Organizer and test
    Click Close. Restart Word and open the document that previously showed the error. The compile error should no longer appear.

Method 3: Disable All Macros Temporarily

  1. Open Trust Center settings
    Click File > Options > Trust Center > Trust Center Settings.
  2. Change macro settings
    Select Macro Settings on the left. Choose “Disable all macros with notification.” This prevents any macro from running when you open a document.
  3. Open the document
    Close the Options dialog and open the document. The compile error should not appear because Word does not attempt to compile the macros.
  4. Re-enable macros after repair
    After you fix the underlying issue using Method 1 or 2, return to Trust Center and select “Disable all macros with notification” or “Enable all macros” if you trust the source. Do not leave macros disabled permanently if you need them.

If Word Still Has Issues After the Main Fix

The Error Appears on Every Document

If the compile error shows on every document you open, the problem is almost certainly in the Normal.dotm template. Follow Method 2 above to delete the hidden module from Normal.dotm. If you cannot delete the module because Word does not start properly, rename the Normal.dotm file. Close Word, navigate to %appdata%\Microsoft\Templates, and rename Normal.dotm to Normal.old. Word creates a fresh Normal template when you restart. This removes all your custom macros, so back up the old file if you need those macros.

The Error Mentions a Specific Add-in

Some third-party add-ins install hidden modules in Word. If the error message includes the name of an add-in, disable that add-in. Go to File > Options > Add-ins. At the bottom of the dialog, choose COM Add-ins from the Manage dropdown and click Go. Uncheck the add-in listed in the error. Restart Word. If the error disappears, contact the add-in vendor for an updated version compatible with your Office build.

The Document Contains Malicious Macros

A compile error can also appear when Word blocks macros from an untrusted source. If you received the document from an unknown sender, do not enable macros. Use Method 3 to open the document with macros disabled. If the document works without macros, the hidden module may contain code you do not want to run. Consider deleting the macros permanently using Method 2 or saving the document as a .docx file, which cannot store VBA code.

Word Hidden Module Error: Trusted vs Untrusted Documents

Item Trusted Document Untrusted Document
Macro behavior Macros run automatically if enabled in Trust Center Macros are blocked by default with a security warning
Compile error visibility Error appears immediately when opening the document Error may appear only after you click Enable Content
Risk of malicious code Low if you trust the source High; do not enable macros unless you are certain of the source
Best fix approach Remove broken references or delete the hidden module Open with macros disabled, then delete the VBA project entirely

After applying the fix, you can open the document without the compile error and use its content normally. If you removed macros, consider whether you need the VBA functionality. For documents you create yourself, save a backup copy of the macro code in a separate .bas file using the VBA editor’s Export File command. This lets you reimport the code later if needed.