How to Save a Template as Macro-Enabled (.dotm) in Word
🔍 WiseChecker

How to Save a Template as Macro-Enabled (.dotm) in Word

You need to save a Word template with embedded macros, but the standard template format (.dotx) does not support macro storage. When you close a .dotx file that contains VBA code, Word silently discards all macros without warning. This article explains how to create and save a macro-enabled template (.dotm) so your code remains intact and usable every time you base a new document on that template.

Key Takeaways: Saving a Macro-Enabled Word Template

  • File > Save As > Browse > Save as type > Word Macro-Enabled Template (.dotm): The only format that preserves VBA macros inside a template file.
  • Developer tab > Visual Basic: Use this to write, test, and store macros before saving the template as .dotm.
  • Trust Center > Macro Settings > Enable all macros: Required setting on the target computer so macros in the .dotm file actually run.

What a Macro-Enabled Template (.dotm) Is and Why You Need It

A Word template is a starting file that contains styles, boilerplate text, page layout settings, and sometimes AutoText entries. The default template format is .dotx, which is a plain XML container that explicitly excludes any executable code. If you add a macro — a VBA subroutine or function — to a .dotx file and save it, Word removes the macro code during the save operation. The result is a template that looks correct but has no functional automation.

The .dotm format solves this problem. The “m” in .dotm stands for macro-enabled. A .dotm file uses the same Open XML structure as .dotx but includes a special binary part that holds VBA project data. When you save a template as .dotm, Word preserves all modules, user forms, and class modules exactly as written.

You need a .dotm template when your template must automate repetitive tasks such as inserting formatted tables, running mail merges, or applying conditional formatting based on document content. Without the .dotm format, those macros will not survive the save operation.

Prerequisites

Before you create a .dotm template, confirm that the Developer tab is visible on the Word ribbon. If it is not, go to File > Options > Customize Ribbon and check the Developer box in the right pane. Also verify that the VBA project is free of compilation errors by pressing Alt+F11, clicking Debug > Compile VBAProject, and fixing any issues that appear.

Steps to Save a Template as Macro-Enabled (.dotm)

The following steps assume you already have a .dotx template or a document that you want to convert to a macro-enabled template. If you are starting from scratch, create a new blank document, add your content and macros, then follow the steps below.

  1. Open the existing template or document
    Double-click the .dotx file or .docm file in File Explorer. If you are converting a regular .docx document, open it normally in Word. Confirm that all macros you intend to keep are present by pressing Alt+F11 and checking the Project Explorer pane.
  2. Click File > Save As
    On the Backstage view, select the Save As command. If you want the template to appear in the New Document gallery, choose the default Templates folder location. The path is usually C:\Users\[YourUserName]\AppData\Roaming\Microsoft\Templates. For a custom location, select any folder you prefer.
  3. Click Browse to open the Save As dialog
    The Browse button opens the standard Windows Save As dialog. Do not use the list of recent folders — use Browse so you can see the file type dropdown.
  4. Open the Save as type dropdown
    In the Save As dialog, locate the dropdown labeled Save as type. The default is usually Word Template (.dotx) or Word Document (.docx). Click the dropdown arrow to see all available formats.
  5. Select Word Macro-Enabled Template (.dotm)
    Scroll down the list and click Word Macro-Enabled Template (dotm). This tells Word to keep the VBA project intact when writing the file. The file extension in the File name field automatically changes to .dotm.
  6. Type a file name and click Save
    Enter a descriptive name for your template. Avoid using special characters such as / ? < > \ : |. Click the Save button. Word writes the template to disk with the .dotm extension and all macros remain embedded.
  7. Close and reopen the .dotm file to confirm macros are preserved
    Close Word completely. Double-click the .dotm file you just saved. Press Alt+F11 to open the Visual Basic Editor. If the module containing your macros is still listed in the Project Explorer, the save was successful.

Alternative Method: Save a Copy from the Visual Basic Editor

If you are working inside the VBA editor and want to export the entire template project, use the File menu inside the editor. This method is useful when you need to save a backup of the VBA code separately.

  1. In the VBA editor, click File > Export File
    Select a module, user form, or class module in the Project Explorer. Click File > Export File and save it as a .bas, .frm, or .cls file. Repeat for each component.
  2. Save the template as .dotm using the previous method
    The export step is optional. You must still save the host file as .dotm to keep the macros inside the template.

Common Mistakes When Saving Macro-Enabled Templates

The .dotm file is saved but macros are missing

This happens when you accidentally select Word Template (.dotx) instead of Word Macro-Enabled Template (.dotm) in the Save as type dropdown. The .dotx format strips all VBA code. To fix this, reopen the original file that still has the macros and repeat the save process, this time selecting .dotm.

Macros do not run when the template is used

Word blocks macros by default for security reasons. Go to File > Options > Trust Center > Trust Center Settings > Macro Settings. Select Enable all macros. Also check Trust access to the VBA project object model if your macros need to modify the VBA environment. After changing these settings, restart Word and open the .dotm file again.

The template does not appear in the New Document gallery

Word only shows templates that are stored in the default Templates folder. If you saved the .dotm file to a different folder, it will not appear under File > New > Personal. Move the .dotm file to C:\Users\[YourUserName]\AppData\Roaming\Microsoft\Templates and restart Word.

Word crashes when opening the .dotm file

A corrupt VBA project causes Word to crash. Open the Visual Basic Editor with Alt+F11, locate the suspect module, and comment out or delete the problematic code. Then save the template again. If the crash persists, create a new blank .dotm file and import the .bas files from the original project.

.dotx vs .dotm: What Changes When You Switch Formats

Item Word Template (.dotx) Macro-Enabled Template (.dotm)
File extension .dotx .dotm
VBA macro support Macros are removed on save Macros are preserved
Security warning on open None (no macros) Yellow bar with Enable Content button
Default save location Custom Office Templates folder Custom Office Templates folder
Can be used as global add-in No Yes, if loaded via Templates and Add-ins
XML structure Open XML with no binary parts Open XML with VBA binary part

The most critical difference is macro preservation. A .dotx file is safe for distribution to users who do not need macros. A .dotm file is required for any template that contains automation code.

You can now create a macro-enabled template that retains all your VBA automation. After saving the .dotm file, test it by basing a new document on the template and running each macro. For advanced use, explore the Templates and Add-ins dialog under Developer > Document Template to load the .dotm as a global template, which makes its macros available to all open documents without requiring a document to be based on it.