The four Word Open XML extensions share one layout. They differ in the content type of the main part, and in whether the file may hold a macro project.
The four kinds
| Extension | What it is | Macros | Main part content type |
|---|---|---|---|
.docx | Document | No | application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml |
.docm | Document | Yes | application/vnd.ms-word.document.macroEnabled.main+xml |
.dotx | Template | No | application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml |
.dotm | Template | Yes | application/vnd.ms-word.template.macroEnabledTemplate.main+xml |
The extension and the content type must agree: Word treats a macro-enabled file renamed
to .docx as an error.
The macro project
Macros are in the part word/vbaProject.bin, reached by a relationship of type
http://schemas.microsoft.com/office/2006/relationships/vbaProject from the main document,
with the content type application/vnd.ms-office.vbaProject.
The part is not XML. It is a Compound File (a small file system with storages and streams), in
the VBA project format that Microsoft documents as MS-OVBA, with the source of each module
compressed. Files that keep macro data for Word’s editing state may also have
word/vbaData.xml, and word/customizations.xml holds Word’s key
bindings.
The viewer on this site lists the project and offers its bytes. It never runs macros.
Templates
A template is laid out in the same way as a document, with a different content type. When a
document is created from a template, the template’s name goes into the
w:attachedTemplate setting (by relationship ID) and the
Template application property. That relationship is usually an external path
or URL.
Building blocks (AutoText, Quick Parts) are held in a glossary document: a part
normally named word/glossary/document.xml, with its own styles, settings and
fonts, reached by a glossaryDocument relationship. Its root is
w:glossaryDocument, and it has a w:docParts list.