How to Fix Word Macros Not Executing and Organize ThisDocument Modules
Question details
The user needs to restore the execution functionality of Word macros and properly organize VBA code to resolve duplicated ThisDocument modules.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Attempting to execute VBA macros and manage macro code structure within the Visual Basic Editor.
- Observed behavior
- Macros are visible in the editor but fail to run. Additionally, multiple numbered copies of the ThisDocument module exist due to repeated exports.
Open your Word Options, navigate to the Trust Center settings, and note your current Trusted Locations paths to ensure you have a designated folder for saving macro-enabled templates.
Clean Up Duplicate ThisDocument Modules and Use Standard Modules
This is the most effective way to eliminate code conflicts by shifting regular macro procedures to standard modules and removing redundant ThisDocument copies.
ThisDocument is a built-in class module strictly designed for document-level events (like opening or closing a file). Repeatedly exporting and importing modules without overwriting can create numbered duplicates (e.g., ThisDocument1, ThisDocument2), which confuses the VBA compiler and prevents macros from executing.
Press Alt + F11 on your keyboard to open the Visual Basic Editor. On the left side, locate the Project Explorer pane.
Expand the Microsoft Word Objects folder. Double-click each numbered ThisDocument module to review the code inside.
Highlight and copy any standard macro code from these duplicates. Then, click Insert > Module from the top menu to create a clean standard module, and paste your code there.
Right-click the redundant ThisDocument numbered copies and select Remove. Keep only the original ThisDocument module, reserving it exclusively for document event code.

Save as a Macro-Enabled Template in a Trusted Location
Use this method if your macros are properly organized but still blocked by application security protocols.
Easily Manage VBA Macros with WPS Writer
WPS Office provides a fully functional VBA editor environment, allowing you to create, edit, and organize your document macros effortlessly without duplicate module glitches.
- 1. Install WPS Office with VBA Support: Download and install WPS Office, ensuring your version includes the VBA module.
- 2. Open Your Macro File: Launch WPS Writer and open your macro-enabled document or template (.docm / .dotm).
- 3. Access the Developer Tools: Navigate to the Developer tab on the ribbon and click the Visual Basic icon to launch the integrated editor.
- 4. Organize Your Modules: Use the Project window to insert standard modules and cleanly separate your ordinary macros from document-level events.

Frequently Asked Questions
Why are there numbered copies of ThisDocument in my VBA project?
Numbered copies (such as ThisDocument1, ThisDocument2) are automatically generated when a module is exported multiple times and the previously exported copies are not overwritten. This clutters the project and can prevent macros from running correctly.
What is the difference between ThisDocument and a standard module?
ThisDocument is a built-in class module that should only be used to handle document-level events, like Document_Open or Document_Close. Standard modules, which you add via Insert > Module, are meant for ordinary procedures and reusable macros.
Why can I see my macros in the Visual Basic Editor but not run them?
This usually occurs because macro security settings block execution from untrusted locations, or because the macros are trapped in conflicting duplicate ThisDocument modules. Moving your code to a standard module and saving the file in a Trusted Location generally resolves the issue.
How do I add a new standard module to my document?
Open the Visual Basic Editor, select your project in the Project Explorer pane on the left, and click Insert > Module from the top menu bar. A blank standard module will appear where you can write or paste your macros.




