How Macros Work in Word: DOCX, DOCM, DOTX, and DOTM Files
Question details
The user wants to understand the behavior and rules for storing, attaching, and invoking VBA macros across various Word document formats, including DOCX, DOCM, DOTX, and DOTM.
- Product
- Word
- Device & OS
- not provided
- Scenario
- Creating, sharing, and executing VBA macros in Word documents while adhering to format limitations and security policies.
- Observed behavior
- A standard DOCX file cannot store VBA project code, requiring users to use attached DOTM templates, macro-enabled formats, or Startup-folder add-ins to utilize macros.
Ensure that the Developer tab is enabled in your word processor's ribbon, and verify your macro security settings to prevent running unauthorized or potentially dangerous code from untrusted sources.
Invoke Macros in a DOCX File via a DOTM Template
Because DOCX files cannot store their own VBA code, you can attach a macro-enabled template (DOTM) to access its embedded macros.
A standard DOCX file is strictly macro-free. However, if the DOCX file is based on or manually attached to a macro-enabled DOTM template, it can successfully invoke the macros stored within that parent template.
Open your macro-free DOCX document in your word processor.
Navigate to the Developer tab on the ribbon and click on 'Document Template'.
Click the 'Attach' button to browse your computer and link your DOTM file containing the necessary macros.
Once attached, you can run the macros from the Macros menu, provided your security settings allow them to execute.
Load Macros Globally Using the Startup Folder
Place a macro-enabled template inside the application's Startup folder to make its macros available globally as an add-in.
Save Macros Directly in DOCM or DOTM Formats
When creating or sharing documents that require embedded macros, save them natively in macro-enabled file formats.
Manage and Run VBA Macros with WPS Office
WPS Office offers comprehensive support for VBA macros in its advanced versions. You can easily open DOCM files, attach DOTM templates, and utilize the built-in Visual Basic Editor to automate your document workflows.
- 1. Download WPS Office: Download and install WPS Office, ensuring you opt for a version that includes VBA capabilities.
- 2. Open your macro file: Launch WPS Writer and open your DOCX, DOCM, or DOTM file.
- 3. Access Developer tools: Navigate to the Developer tab on the top ribbon to open the Visual Basic Editor, manage Document Templates, and run your macros.

Frequently Asked Questions
Can a standard DOCX file contain VBA macros?
No, a standard DOCX file is designed to be macro-free and cannot store VBA project code. If you attempt to save a document containing macros as a DOCX, the macro code will be stripped. To embed macros directly within the file, you must save it as a Macro-Enabled Document (DOCM).
Why aren't macros from Normal.dotm available in all my documents?
Macros stored in Normal.dotm typically apply only to documents that are explicitly created based on that specific template. To make macros universally available across all open files, consider placing a macro-enabled template inside the application's Startup folder, which loads it as a global add-in.
Are DOCM and DOTM files safe to open?
Because DOCM and DOTM files can contain executable VBA code, they inherently carry a security risk if they are obtained from untrusted sources. You should always keep your macro security settings set to prompt you before executing any code, ensuring you only run macros from verified and trusted authors.




