How to Convert .docm to .docx Without Losing Macros
🔍 WiseChecker

How to Convert .docm to .docx Without Losing Macros

You have a Word document with the .docm extension that contains macros, and you need to save it as a .docx file. The .docx format does not support macros, so a normal Save As operation will either strip the macros silently or prompt you to remove them. This article explains how to extract and store your macros before converting the document, so you can keep the macro code for future use. You will learn two methods: exporting macros to a separate file and storing them in a global template.

Key Takeaways: Preserve Macros When Converting .docm to .docx

  • Export macros to a .bas file via Visual Basic Editor: Saves the macro code outside the document so you can import it later.
  • Store macros in a global template (Normal.dotm): Keeps macros available to all documents without embedding them in the .docx file.
  • Save As .docx after removing macros: Word will not warn about compatibility because the macro code is no longer in the file.

ADVERTISEMENT

Why Macros Are Removed When Saving .docm as .docx

The .docm file format is the macro-enabled version of the Word Open XML format. It stores Visual Basic for Applications code in a separate stream inside the file. The .docx format, by design, cannot contain executable code. When you use File > Save As and choose .docx, Word automatically removes all macro modules from the document. The macros are not hidden or disabled — they are permanently deleted from the file. If you close the document after saving, the original macro code is lost unless you back it up beforehand.

This behavior is a security measure. Because .docx files cannot contain macros, they are safer to share with external recipients who may not expect executable code. However, if you are the author and need to keep the macros for your own workflow, you must extract them before converting the document. There is no built-in Word command that copies macros to a new location automatically. You must use the Visual Basic Editor or the Organizer dialog to move the code manually.

How to Extract Macros From a .docm File Before Converting

The following steps show two reliable methods to preserve your macros. Choose the method that fits how you plan to use the macros later.

Method 1: Export Macros to a .bas File

Exporting macros to a .bas file creates a standalone copy of the VBA code. You can import this file into any other document or template later. This method is best when the macros are specific to one document.

  1. Open the .docm file in Word
    Double-click the file or open it from Word using File > Open. If you see a security warning bar, click Enable Content to allow the macros to run. You do not need to run the macros to export them, but the VBA project must be accessible.
  2. Open the Visual Basic Editor
    Press Alt+F11 on your keyboard. The VBA editor window opens. In the Project Explorer pane on the left, locate the project that corresponds to your document. It is usually named with the document filename.
  3. Expand the project tree
    Click the plus sign next to the project name to see the folder called Modules. If your macros are in a module, you will see it listed here. If the macros are in the ThisDocument object, they are stored in the document code pane instead of a separate module.
  4. Right-click the module and choose Export File
    In the Project Explorer, right-click the module name and select Export File from the context menu. A standard Save As dialog appears. Choose a folder on your computer, enter a filename with a .bas extension, and click Save. Repeat this step for each module you need to export.
  5. Export code from the ThisDocument object if needed
    If your macros are inside the ThisDocument code pane, double-click ThisDocument in the Project Explorer. Press Ctrl+A to select all code, then Ctrl+C to copy it. Open Notepad, paste the code, and save the file with a .txt extension. You can later copy the code back into a module.
  6. Close the Visual Basic Editor
    Press Alt+Q or click the close button to return to the Word document window.
  7. Remove macros from the document
    Press Alt+F11 again to open the editor. In Project Explorer, right-click each module and choose Remove Module. Confirm the removal. Do not click Export — you already saved the files. Close the editor.
  8. Save the document as .docx
    Go to File > Save As. Choose Word Document (.docx) from the Save as type list. Click Save. Word will not show a warning because no macros remain in the file.

Method 2: Store Macros in the Normal Template (Normal.dotm)

If you want the macros to be available globally for all documents, you can copy them into the Normal template. This method keeps the macros outside the .docx file so you can still use them later.

  1. Open the .docm file and enable macros
    Open the file in Word and click Enable Content on the security bar if prompted.
  2. Open the Organizer dialog
    Press Alt+F11 to open the Visual Basic Editor. In the menu bar, click Tools > VBAProject Properties. This step is not required for the Organizer — close the dialog if it opens. Instead, go back to the Word window. Press Alt+F8 to open the Macros dialog, then click Organizer. Alternatively, go to View > Macros > Organizer from the ribbon.
  3. Switch to the Macro Project Items tab
    In the Organizer dialog, click the tab labeled Macro Project Items. The left pane shows the modules from your open .docm file. The right pane shows modules from the Normal.dotm template.
  4. Copy modules to Normal.dotm
    In the left pane, select the module you want to copy. Click the Copy button. Word copies the module to the Normal template. Repeat for each module. If a module with the same name exists in Normal.dotm, Word asks whether to overwrite it. Choose Yes if you want to replace it.
  5. Close the Organizer and save Normal.dotm
    Click Close. When Word prompts you to save changes to Normal.dotm, click Save. The macros are now stored in the global template.
  6. Remove macros from the .docm file
    Open the Visual Basic Editor with Alt+F11. In Project Explorer, right-click each module and choose Remove Module. Confirm the removal. Close the editor.
  7. Save the document as .docx
    Go to File > Save As. Choose Word Document (.docx) and click Save.

ADVERTISEMENT

Common Problems When Converting .docm to .docx

Word Prompts You to Remove Macros During Save As

If you attempt to save a .docm file as .docx without removing the macros first, Word displays a warning that the new file will not contain the VBA code. Clicking Yes removes the macros permanently. To avoid this, always export or move the macros before saving as .docx. If you accidentally clicked Yes, reopen the original .docm file — the macros are still in the original file as long as you did not overwrite it.

Macros Are Not Visible in the Organizer Dialog

The Organizer dialog shows only modules that are stored in the VBA project. If your macros are embedded in the ThisDocument code pane, they will not appear in the Organizer. You must export that code manually by copying and pasting it to a text file as described in Method 1. Alternatively, you can move the code from ThisDocument to a standard module before using the Organizer.

Imported Macros Do Not Work in the New .docx File

Even if you import a .bas file into a .docx document, the macros will not run because the .docx format does not allow executable code. You must keep the macros in a .docm file or in a global template. The .docx file itself can never contain macros. If you need to run the macros while working with the .docx content, store the macros in Normal.dotm and run them from there.

Comparison of Methods for Saving Macros When Converting .docm to .docx

Item Export to .bas File Store in Normal.dotm
Where macros are saved External .bas file on disk Global template Normal.dotm
Macros available after conversion Only if you import them into another .docm file Available to all documents opened in Word
Ease of sharing with others Send the .bas file alongside the .docx Others must install the macros in their own Normal.dotm
Risk of losing macros Low if you save the .bas file in a safe location Low if you back up Normal.dotm regularly
Best for Document-specific macros you may need later Macros you use frequently across many documents

Converting a .docm file to .docx does not have to mean losing your macros. By exporting the VBA code to a .bas file or copying it into the Normal template, you keep the macros safe and reusable. After conversion, the .docx file is macro-free and suitable for sharing. If you need to run the macros again, import the .bas file into a new .docm document or rely on the Normal.dotm template. For quick access, consider creating a custom ribbon tab that calls macros stored in Normal.dotm.

ADVERTISEMENT