Word VBA: Attach a DOTM Template or Install It as an Add-In
Question details
Compare installing a DOTM file as a Word add-in with attaching it to the active document.

- 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.
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.
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.
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.
For the active document, use ActiveDocument.AttachedTemplate = "C:\Templates\MyTemplate.dotm" in the VBA editor. Replace the example path with the actual DOTM path.
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.
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.

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.

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.




