Office Settings & Configuration

Word VBA: Attach a DOTM Template or Install It as an Add-In

Huda QurayshiHuda Qurayshi Nov 25, 2026 868 views

Question details

Compare installing a DOTM file as a Word add-in with attaching it to the active document.

Word VBA: Attach a DOTM Template or Install It as an Add-In
Product
Microsoft Word VBA
Device & OS
not provided
Scenario
A user wants to choose how to use a DOTM template's macros, customizations, styles, and XML schema settings.
Observed behavior
The desired outcome is to understand which template role provides the required features and whether automatic style updates or XML validation are needed.
Before you start

Identify the DOTM file and decide whether its features should be available across documents or primarily to one document. Check Word's macro security and trusted-location settings before running code from the template.

Solution 1Recommended

Choose an add-in or an attached template based on its role

Install the DOTM as an add-in for broadly available customizations, or attach it when it serves as the document's template.

An installed template add-in can make its macros, keyboard shortcuts, and user-interface customizations available across Word documents. An attached template is associated with a particular document and can provide styles and template-specific macros and customizations.

Attaching a template does not require automatic style updates. Using the same file in both roles is usually unnecessary, although the choice depends on the scope and features you need.

1
Install a global add-in

In the VBA editor, use AddIns.Add FileName:="C:\Templates\MyTemplate.dotm", Install:=True to install the template as an add-in. Replace the example path with the actual DOTM path.

2
Attach a document template

For the active document, use ActiveDocument.AttachedTemplate = "C:\Templates\MyTemplate.dotm" in the VBA editor. Replace the example path with the actual DOTM path.

3
Control style updates

Set ActiveDocument.UpdateStylesOnOpen = False in the VBA editor if you do not want matching document styles automatically updated from the attached template when the document opens.

4
Review XML validation needs

Configure XMLSchemaReferences validation settings only if the document is part of an XML-schema workflow that requires validation. Validation restrictions can prevent saving when a document does not meet the applicable schema requirements.

Choose an add-in or an attached template based on its role
Watch for formatting changes: Enabling automatic style updates can replace matching document style definitions with those from the attached template, changing the document's formatting.
Free Microsoft Office alternative

Edit Word Documents with WPS Writer

WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Word documents. Its format compatibility helps you move everyday documents between Microsoft Office and WPS Office; it does not fix Word's VBA template or XML validation settings.

Open and edit Microsoft Word DOC and DOCX filesWork with document styles in WPS WriterUse a familiar interface for everyday document editingMove compatible documents between Office suites without starting over
microsoft office alternative - wps office

Frequently Asked Questions

What is the main difference between a Word add-in and an attached template?

A template installed as an add-in can provide macros and customizations across documents. An attached template is associated with a specific document and can provide its styles and template-specific features.

Do I need to install and attach the same DOTM file?

Usually not. Choose an add-in for broadly available features or an attached template for a document-specific association. Use both only if your workflow requires both roles.

Why did my document formatting change after opening it?

If UpdateStylesOnOpen is enabled, Word can update matching document styles from the attached template. Set ActiveDocument.UpdateStylesOnOpen = False in VBA to prevent automatic updates on open.

Are XML schema validation settings required for every template?

No. XMLSchemaReferences validation settings are relevant to workflows that use XML schemas. Depending on the validation restrictions configured, a document that fails validation may be prevented from being saved.

Why aren't my DOTM macros running?

Check Word's macro security settings and whether the template is in a trusted location. Only enable macros or trust a location when you trust the template and its source.