When you open Word, you may see a dialog box that says “Compile error in hidden module” followed by a module name. This error blocks your document from loading or causes Word to crash immediately. The root cause is almost always a corrupted or incompatible VBA macro stored inside an old Word template, such as Normal.dotm or a global add-in template. This article explains why old templates trigger the error and provides a step-by-step method to locate, remove, or repair the offending template so Word opens normally.
Key Takeaways: Removing a Corrupt VBA Module From an Old Template
- File > Options > Add-ins > Manage COM Add-ins > Go: Disable all third-party add-ins that may host hidden modules.
- %appdata%\Microsoft\Templates > Rename Normal.dotm: Forces Word to create a fresh default template, eliminating old macros.
- Developer tab > Visual Basic > Project Explorer > Modules: Manually delete or export suspicious modules from a trusted template.
Why an Old Template Causes a Compile Error in a Hidden Module
Word templates can contain VBA macros stored inside modules. When you open Word, it loads all global templates and add-ins specified in the Startup folder or the Templates folder. If any template contains a macro module that references a missing object library, uses outdated syntax, or has a corrupted line of code, the VBA compiler fails during startup. Because the module is marked as “hidden” in the VBA project properties, Word does not show the code in the Visual Basic Editor by default. The error message appears without a clear way to fix it.
The most common culprit is the Normal.dotm template. This template is the default global template that Word loads every time it starts. Over time, Normal.dotm can accumulate old macros from third-party installations, previous Office versions, or manual code additions. Other templates in the Word Startup folder or the Templates folder can also trigger the same error.
The error is not a document corruption issue. It is a template corruption or incompatibility issue. Even if you open a blank document, the error will appear because Word loads the template before showing the document.
Steps to Remove the Offending Template and Fix the Error
Follow these steps in order. Stop after each step and restart Word to see if the error is gone. Do not skip steps.
Step 1: Disable All Add-ins
- Open Word in Safe Mode
Press and hold the Ctrl key while double-clicking the Word icon. Click Yes when prompted. If Word opens without the error, a template or add-in is the cause. Close Word after testing. - Disable COM Add-ins
Go to File > Options > Add-ins. At the bottom, next to Manage, select COM Add-ins and click Go. Clear all checkboxes. Click OK. Restart Word normally. If the error disappears, re-enable add-ins one at a time to find the culprit. - Disable Other Add-ins
In the same Add-ins dialog, change Manage to Word Add-ins and click Go. Clear all checkboxes. Click OK. Restart Word.
Step 2: Rename the Normal.dotm Template
- Close Word completely
Make sure no Word process is running. Check Task Manager if needed. - Open the Templates folder
Press Win+R, type%appdata%\Microsoft\Templates, and press Enter. - Rename Normal.dotm
Right-click Normal.dotm and choose Rename. TypeNormal_old.dotmand press Enter. - Start Word
Word creates a fresh Normal.dotm with no macros. If the error is gone, your old Normal.dotm was the problem. You can delete Normal_old.dotm after confirming.
Step 3: Check the Word Startup Folder
- Open the Startup folder
In Word, go to File > Options > Advanced. Scroll to the General section and click File Locations. Select Startup and click Modify. Note the folder path. - Move templates out of the Startup folder
Close Word. Open the Startup folder in File Explorer. Move all .dotm, .dot, and .dotx files to a temporary folder on your desktop. Restart Word. If the error stops, one of those templates was the cause. Add templates back one at a time to identify which one.
Step 4: Remove Hidden Modules From a Specific Template
If you know which template is causing the error and you want to keep the template, you can remove only the hidden module.
- Open the template in Word
In Word, go to File > Open. Browse to the template file. Change the file type filter to All Files or Word Template. Select the template and click Open. - Open the Visual Basic Editor
Press Alt+F11. In the Project Explorer pane, find the template project. It may show as TemplateProject or the template file name. - Unhide and delete the module
In the Project Explorer, right-click the project name and choose Properties. On the Protection tab, clear Lock project for viewing. Click OK. Expand the Modules folder. Right-click the module named in the error message and choose Remove Module. Click No when asked to export. Save the template. - Save and close
Close the Visual Basic Editor. Save the template. Close Word and reopen it normally.
If Word Still Has Issues After the Main Fix
Word Opens but the Error Appears When Opening a Specific Document
The error may be attached to a document that contains a hidden module in its VBA project. Open the document with macros disabled: hold the Shift key while double-clicking the document. Then open the Visual Basic Editor and check for modules. Delete any suspicious modules as shown above.
The Error Mentions a Missing Reference
If the compile error says “Can’t find project or library,” open the Visual Basic Editor and go to Tools > References. Look for any item marked MISSING. Clear the checkbox for that reference. Save the template and restart Word.
The Error Returns After Re-adding a Template
The template likely has a macro that references a specific Office version or library. You can copy the useful macros to a new template by exporting each module from the old template and importing it into a fresh .dotm file. Use File > Export File in the Visual Basic Editor to save the module code, then import it into a new template.
Safe Mode vs Normal Mode: How Templates Load Differently
| Item | Safe Mode | Normal Mode |
|---|---|---|
| Normal.dotm loaded | No, Word uses a temporary default | Yes, loads the existing Normal.dotm |
| COM add-ins loaded | No | Yes |
| Word add-ins loaded | No | Yes |
| Startup folder templates | No | Yes |
| VBA macros executed | No | Yes |
This table explains why opening Word in Safe Mode bypasses the compile error. Safe Mode loads no templates and no add-ins, so the hidden module never runs. Use Safe Mode as a diagnostic tool to confirm the error is template-related.
After you remove or repair the offending template, the error will not return unless you introduce another corrupted template. To prevent future errors, disable macros from unknown sources and keep only essential templates in the Startup folder. Use the Developer tab to export any macros you need before deleting a template.