File Format & Compatibility

Understanding DOCX vs DOCM: How to Save Macros in Microsoft Word

Natalie TaylorNatalie Taylor Nov 2, 2026 876 views

Question details

The user needs to understand the difference between DOCX and DOCM formats, specifically regarding how Microsoft Word stores and executes VBA macros.

Understanding DOCX vs DOCM: How to Save Macros in Microsoft Word
Product
Microsoft Word
Device & OS
not provided
Scenario
Saving a Word document that contains VBA macros without losing the macro code.
Observed behavior
When saving a macro in a DOCX file, Word displays a warning and removes the macro code. Macros must be saved in a DOCM file to be retained, though DOCX files can still run macros stored in global templates.
Before you start

Before saving your document, determine whether it requires embedded VBA macros to function or if it will rely on personal macros stored locally in your global templates.

Solution 1Recommended

Save the Document as a Macro-Enabled Format (DOCM)

Use the DOCM format when you need to embed and retain VBA code directly within your Word document so it can be shared with others.

While you can record or write a macro while working in a standard DOCX file, Microsoft Word will not allow you to save the macro in that format. You must choose the macro-enabled format to prevent losing your code upon saving.

1
Initiate the Save As command

Click on 'File' in the top-left corner of Microsoft Word and select 'Save As' to choose your desired destination folder.

2
Select the DOCM format

In the 'Save as type' dropdown menu, scroll through the list and select 'Word Macro-Enabled Document (*.docm)'.

3
Save the file

Click the 'Save' button. Your document will now retain both its textual content and the embedded VBA macros.

Save the Document as a Macro-Enabled Format (DOCM)
Template Differences: This same distinction applies to Word templates. Standard templates use DOTX, while macro-enabled templates must be saved as DOTM.
Seamless Document Editing

Open and Save DOCX and DOCM Files in WPS Office

WPS Office provides excellent compatibility with Microsoft Word formats. You can effortlessly open, edit, and save standard DOCX documents, as well as handle macro-enabled formats using WPS Writer.

  1. 1. Download WPS Office: Download and install the free WPS Office suite on your computer.
  2. 2. Open your file: Launch WPS Writer, click on 'Menu', select 'Open', and choose your DOCX or DOCM file.
  3. 3. Edit and save: Make the necessary edits to your document. Click 'Menu' > 'Save As' and select 'Word Macro-Enabled Document (*.docm)' if you need to retain VBA macros.
Fully compatible with Microsoft Word DOCX and DOCM formatsFamiliar user interface makes switching effortlessLightweight software that runs quickly on multiple operating systemsCompletely free to download and use for essential document processing
microsoft office alternative - wps office

Frequently Asked Questions

Why did my macros disappear after saving a DOCX file?

DOCX files are deliberately designed without the ability to store executable code for security reasons. If you save a document containing macros as a DOCX, Word automatically strips the VBA code to keep the file safe. To retain your code, you must save the file as a DOCM.

What is the difference between DOTX and DOTM?

DOTX is a standard Microsoft Word template format, while DOTM is a macro-enabled template. Just like the relationship between DOCX and DOCM, you must use DOTM if you want your template to store VBA macros.

How do I run a macro in a DOCX file if it cannot be saved?

While the DOCX file itself cannot store the macro code, it can execute macros that are saved in your computer's global template (Normal.dotm) or another attached template while the document remains open.

Can a standard DOCX file contain a macro virus?

Because DOCX files are technically incapable of storing VBA macros, they carry a significantly lower risk of containing macro-based viruses. This strict separation is the primary reason Microsoft introduced the independent DOCM format.