Why Word Templates Lose Custom Styles When Saved as .dotx Versus .dotm
🔍 WiseChecker

Why Word Templates Lose Custom Styles When Saved as .dotx Versus .dotm

You created a custom template with carefully designed styles, but after saving it as a .dotx file, those styles disappeared when you reopened the template or applied it to a new document. This happens because .dotx files cannot store macros or VBA code, and some style behaviors depend on macro-enabled features. This article explains the technical difference between .dotx and .dotm formats, why styles can appear to be lost, and how to preserve every custom style by using the correct file format.

Key Takeaways: .dotx vs .dotm and Custom Style Retention

  • File > Save As > Word Template (.dotx): Strips all VBA macros and style-linked code, causing style loss if the style depends on a macro.
  • File > Save As > Word Macro-Enabled Template (.dotm): Preserves all macros and style-related code, keeping styles fully intact.
  • Developer > Visual Basic > Project Explorer: Check for any macro or code attached to a style; save as .dotm if any code exists.

ADVERTISEMENT

Why .dotx and .dotm Handle Styles Differently

Word template files come in two primary formats: .dotx (Word Template) and .dotm (Word Macro-Enabled Template). The core difference is that .dotx files cannot contain VBA macros, ActiveX controls, or any executable code. .dotm files can contain all of these. This distinction directly affects how custom styles behave.

When you create a custom style in Word, the style definition is stored inside the template. Most styles — font, size, color, paragraph spacing, borders, shading — are purely formatting data. These styles save and load correctly in either .dotx or .dotm format. The problem occurs when a style is linked to a macro or relies on VBA code to apply or update its formatting.

Scenarios Where Styles Depend on Macros

A style can appear to lose its formatting if any of the following are true:

  • The style uses a macro to apply conditional formatting based on document content.
  • The style was created by a third-party add-in that injects VBA code into the template.
  • The template contains an AutoOpen or AutoNew macro that modifies styles when the template loads.
  • The style is part of a custom Ribbon or Quick Access Toolbar command that runs a macro.

When you save as .dotx, Word silently removes all VBA code. Any style that depended on that code will break. The style definition might still appear in the Styles pane, but its formatting may revert to default or behave unpredictably.

Steps to Check and Fix Style Loss in Templates

Follow these steps to determine if your styles are affected by macro removal and to save the template correctly.

  1. Open the template in Word
    Double-click the .dotx or .dotm file to open it as a template. Do not create a new document from it. If the file is already open, close it and reopen directly.
  2. Open the Visual Basic Editor
    Press Alt+F11 to open the VBA editor. In the Project Explorer pane on the left, expand the project that matches your template name. Look for modules under Modules, Class Modules, or ThisDocument.
  3. Check for macros attached to styles
    Double-click any module or ThisDocument entry to view the code. Look for Sub procedures named AutoOpen, AutoNew, Document_Open, or any Sub that references Styles or Style objects. If you see such code, the template contains style-related macros.
  4. Close the VBA editor and go to File > Save As
    In the Save As dialog, click the Save as type dropdown. Select Word Macro-Enabled Template (.dotm). Choose a location and click Save. This preserves all macros and style code.
  5. Test the saved .dotm template
    Close Word. Double-click the .dotm file to open a new document based on it. Apply your custom styles and verify that formatting appears exactly as intended.

If You Intentionally Need a .dotx File

If your organization requires .dotx files for security or compatibility reasons, you must remove all macro dependencies from your styles before saving. Do the following:

  1. Remove all VBA code from the template
    Press Alt+F11. In the Project Explorer, right-click each module and choose Remove. Confirm the removal. Delete any code in the ThisDocument object by selecting all text and pressing Delete.
  2. Manually recreate style formatting
    For each custom style that relied on macros, open the style in the Modify Style dialog. Set all formatting properties — font, size, color, paragraph spacing, borders — directly in the dialog. Do not rely on any macro to apply formatting later.
  3. Save as .dotx
    Go to File > Save As. Choose Word Template (.dotx). Click Save. The template now contains only static style definitions.

ADVERTISEMENT

If Word Still Shows Style Problems After Saving as .dotm

Styles still look different after saving as .dotm

This typically means the style was not dependent on a macro at all, but rather the style definition itself was corrupted during a previous .dotx save. Open the template, open the Styles pane by pressing Alt+Ctrl+Shift+S, right-click the problematic style, and choose Modify. Reset all formatting to match your desired appearance. Then save again as .dotm.

Word warns about macros when opening the .dotm file

This is expected behavior. Word displays a security warning for any template containing macros. If you trust the source, click Enable Content. If you want to avoid the warning, you must remove all macros and save as .dotx, but doing so may break style features again.

The template was shared with others and styles are missing

If the recipient opens a .dotm file and macros are disabled, style-related macros will not run. Instruct recipients to enable macros when opening the template. Alternatively, convert all style formatting to static definitions and save as .dotx to remove the dependency.

Item .dotx (Word Template) .dotm (Macro-Enabled Template)
Stores VBA macros No — all macros are removed on save Yes — macros are preserved
Style formatting retention Static styles only; any macro-linked style breaks All styles retained, including macro-linked
Security warning on open None — no executable content Yes — macro warning appears
Compatibility with older Word Works with Word 2007 and later Works with Word 2007 and later
Recommended use case Simple templates with no code Templates with macros, custom Ribbon, or style automation

You can now confidently choose the correct file format for your Word templates. If your custom styles depend on macros, always save as .dotm. For templates with only static formatting, .dotx is safe and avoids macro warnings. To check for hidden macro dependencies, use the Visual Basic Editor with Alt+F11 before saving.

ADVERTISEMENT