The basics
What is a DOCM file?
DOCM is the format Word uses for documents that contain macros: small programs written in VBA (Visual Basic for Applications) that automate the document, for example filling in fields, formatting a report or adding a custom button. When you add a macro to a document and save it, Word asks you to save it as a Word Macro-Enabled Document, with the extension .docm.
Microsoft introduced it with Office 2007, alongside DOCX. The older DOC format used one extension whether or not there were macros inside. With the XML formats, Microsoft split them: a .docx can't hold macros, and a .docm can. The point was to make files with code in them easy to recognise.
- It's a DOCX with one difference. Same ZIP package, same XML. The main part has a different content type, and the package may contain a VBA project.
- "Macro-enabled" doesn't mean "has macros". It means the file is allowed to. Our samples are DOCM files with no VBA project at all.
- Opening it doesn't run the macros by itself. Whether they run is decided by Office's macro settings, Windows' Mark of the Web and the choices you make, explained below.
Our samples contain no macros
Every DOCM on this page is the macro-enabled package type without a VBA project. They are safe to open, and olevba reports "No VBA or XLM macros found" for each one.
Anatomy
What's inside a DOCM file
A DOCM is built exactly like a DOCX: a ZIP archive of XML parts. Our sample-minimal.docm has the three parts a document needs and no macros. The last lines show what Word adds when a document does have macros; none of that is in our sample.
$ unzip -l sample-minimal.docm
Length Date Time Name
--------- ---------- ----- ----
415 2026-10-27 12:00 [Content_Types].xml
303 2026-10-27 12:00 _rels/.rels
577 2026-10-27 12:00 word/document.xml
First 4 bytes: 50 4b 03 04 (PK..)
[Content_Types].xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
<Default Extension="xml" ContentType="application/xml"/>
<Override PartName="/word/document.xml" ContentType="application/vnd.ms-word.document.macroEnabled.main+xml"/>
</Types>
A .docm that really has macros also contains (NOT in this sample):
word/vbaProject.bin the VBA project
word/_rels/document.xml.rels <Relationship Type="http://schemas.microsoft.com/office/2006/relationships/vbaProject" Target="vbaProject.bin"/>
word/vbaData.xml VBA supplemental data
[Content_Types].xml <Default Extension="bin" ContentType="application/vnd.ms-office.vbaProject"/>- 1
50 4b 03 04The ZIP signature
The same first bytes as every DOCX, XLSX and ZIP file. Nothing at the start of the file says "macros": a tool has to open the package to find out.
- 2
[Content_Types].xmlThe content types
Lists the type of every part. This is where a DOCM and a DOCX differ, and in our minimal samples it's the only place.
- 3
ContentType="application/vnd.ms-word.document.macroEnabled.main+xml"The macro-enabled main part
The main document part of a DOCX has the type
…wordprocessingml.document.main+xml. This one says the package is a macro-enabled document. Word reads it to decide what kind of file it has opened, and it must agree with the.docmextension. - 4
_rels/.relsThe package relationships
Points to
word/document.xml, exactly as in a DOCX. - 5
word/document.xmlThe document
Ordinary WordprocessingML: paragraphs, runs and text. Macros never live in the document XML.
- 6
word/vbaProject.binThe VBA project (not in our sample)
Where the macros are. It's a binary file in the older OLE compound file format, the same container as a DOC, with the VBA source code inside. A DOCM without this part has no macros.
- 7
Type="http://schemas.microsoft.com/office/2006/relationships/vbaProject"The link to the macros
The document part points to the VBA project with this relationship type. Readers find the project through the relationship, not by its file name.
- 8
word/vbaData.xmlSupplemental data
An XML part only Word uses, holding extra information about the macros. [MS-OFFMACRO2] calls it the VBA supplemental data part.
- 9
ContentType="application/vnd.ms-office.vbaProject"The VBA content type
The type of the VBA project part. Word declares it for the
.binextension.
Under the hood
Where the macros are stored
The macros sit in one part, usually named word/vbaProject.bin. Unlike the rest of the package, it isn't XML. It's an OLE compound file, the "file system inside a file" that Office used before 2007, laid out as [MS-OVBA] specifies:
| Inside vbaProject.bin | What it holds |
|---|---|
VBA storage | The project itself: a dir stream describing the project and its modules, a _VBA_PROJECT stream, and one stream per module. |
| Module streams | The source code of each module, compressed, such as ThisDocument and any modules you add. |
| Performance cache | Compiled code for the version of Office that saved the file. The specification treats it as version-specific and tells other programs to ignore it. |
PROJECT stream | Project-level settings as text, such as the project name and whether it is password-protected for viewing. |
Word links the document to the project with a relationship of type …/2006/relationships/vbaProject, declares the content type application/vnd.ms-office.vbaProject for it, and adds a small XML part, word/vbaData.xml, with Word-specific data about the macros. A signed project also carries a signature part.
Converting a DOCM to a DOCX in code is the reverse: Microsoft's Open XML SDK guide removes the vbaProject part, changes the document type to a normal document, which rewrites the main content type, and only then renames the file. Deleting the part alone isn't enough.
Renaming
Why renaming a DOCM to DOCX doesn't help
Word checks that the extension of an Office Open XML file agrees with the content type of its main part. Cisco Talos described this check in 2016: a DOCX renamed to .docm makes Word show an error instead of opening it. The check works both ways, so a DOCM renamed to .docx is refused too, with its macros still inside. Renaming changes nothing in the package.
| You rename a .docm to… | What happens |
|---|---|
.docx | Word reports a problem with the file instead of opening it, because the main part still says macro-enabled. |
.doc or .rtf | Word looks at the content, not the name, and opens it as the DOCM it is, macros included. Talos showed this in 2016, and attackers used it to hide macro documents behind harmless-looking extensions. |
.zip | Any archive tool opens it, so you can look inside safely. Nothing runs. |
To remove macros for real, open the document in Word and save it as a Word Document (.docx). Word warns that the VBA project can't be saved in a macro-free document and leaves it out if you continue.
Judge the content, not the name
Mail filters and upload checks that only look at the extension can be fooled. Look inside the package for a vbaProject part, or run a tool such as olevba, whatever the file is called. Our sample-content-type-mismatch.docm is a DOCX package under a .docm name, for testing exactly that.
Security
How Office decides whether macros run
Macros have been one of the most common ways to spread malware through email for decades, so Office doesn't run them just because a document contains them. Since 2022, Office on Windows blocks macros in files that came from the internet by default. It recognises those files by the Mark of the Web: a note Windows attaches to a file saved from a browser or an email attachment, recording that it came from the Internet zone.
When you open a DOCM with macros, Office on Windows checks, in this order:
- 1Trusted Location. A file in a folder set as a Trusted Location opens with macros enabled.
- 2Digital signature. Macros signed by a publisher whose certificate is in your Trusted Publishers list are enabled.
- 3Policy. Group Policy or cloud policy set by an organisation can block or allow macros.
- 4Mark of the Web. If the file came from the internet and none of the above applies, the macros are blocked and a red Security Risk banner appears. It has no button to enable them.
- 5Otherwise (a file you made, or from your own network), the usual yellow Security Warning bar appears, with an Enable Content button.
Before any of that, a document from the internet usually opens in Protected View: read-only, with most editing turned off, until you choose Enable Editing. That is a separate safeguard for every Office file, with or without macros.
- To unblock a file you trust: right-click it, choose Properties and tick Unblock on the General tab, or run
Unblock-Filein PowerShell. Both remove the Mark of the Web. - Not affected by the 2022 change: Office for Mac, Office on iPhone, iPad and Android, and Office on the web. The web versions don't run VBA anyway.
- Documents that ask you to enable content are the classic trick: the text claims the document is "protected" or "created in a newer version" and tells you to click Enable Content. Don't.
Inspection
How to check a DOCM for macros safely
You don't need to open a document in Word to see whether it contains macros, and you shouldn't open a suspicious one there anyway. Two ways that never run any code:
- List the parts.
unzip -l file.docm, or rename a copy to.zipand open it. AvbaProject.binanywhere in the package means there is a VBA project. - Use olevba. It's part of oletools, a free Python package for analysing Office files (
pip install oletools). It extracts the VBA source code without running it and flags auto-run macros, such asAutoOpenandDocument_Open, and suspicious keywords. Its companionmraptorgives a quick verdict on whether macros look malicious.
$ olevba sample-document.docm
olevba 0.60.2 on Python 3.13.16 - http://decalage.info/python/oletools
===============================================================================
FILE: sample-document.docm
Type: OpenXML
No VBA or XLM macros found.If a document does have macros you want to read, open it in Word with macros disabled and press Alt+F11 for the VBA editor. Reading the code there doesn't run it.
Comparison
DOCM vs DOCX, DOC, DOTM and PDF
| DOCM | DOCX | DOC | DOTM | ||
|---|---|---|---|---|---|
| Structure | ZIP of XML, plus a binary VBA part | ZIP of XML | OLE compound file | ZIP of XML, plus a binary VBA part | Binary objects and streams |
| Can hold VBA macros | Yes | No | Yes | Yes | No (but JavaScript) |
| Macros visible from the name | Yes | Yes, there are none | No | Yes | n/a |
| Made for | Documents with automation | Ordinary documents | Word 97 to 2003 | Templates and add-ins with macros | Final, fixed pages |
If a document only needs to be read, send it as DOCX or PDF: many organisations' mail filters block macro-enabled attachments, and the reader can't run the macros from an email anyway. Keep DOCM for documents whose macros the reader needs, and tell them what the macros do. Macros meant for every document belong in a DOTM template instead.
How to
How to open, edit and convert a DOCM file
- Microsoft Word on Windows and Mac opens and saves DOCM, with full VBA support.
- Word for the web opens the document but doesn't run VBA macros.
- LibreOffice Writer opens DOCM files and can keep the VBA project, but it has its own macro security settings and runs only part of the VBA language.
- Convert to DOCX: in Word, File, Save As, Word Document (.docx). The VBA project is left out.
- Convert to PDF: File, Save As, PDF in Word, or
soffice --headless --convert-to pdf file.docmon a server. Neither runs the macros. - In code: python-docx's
Document()refuses a DOCM with "is not a Word file", because it accepts only the DOCX content type. Lower-level libraries such as the Open XML SDK open it and expose the VBA part.
Troubleshooting
Common DOCM problems and how to fix them
- "Microsoft has blocked macros from running because the source of this file is untrusted." The file has the Mark of the Web. If you trust it and need the macros, unblock it in its Properties, or ask your IT team for a Trusted Location or a signed version.
- Word refuses a file after you renamed it. The extension no longer matches the content type. Rename it back to
.docm, then save it as.docxfrom Word if you want it without macros. - My macros disappeared. The document was saved as
.docx, which can't hold them. Use the.docmcopy, or a backup. - The attachment was blocked or stripped. Many mail systems block macro-enabled Office files. Share it as a link or as a zipped file, if your organisation allows it, or send a DOCX or PDF.
- A converter or library rejects it. Some tools accept only the DOCX content type. Use one that supports macro-enabled documents, or convert to DOCX first in Word.
Free downloads
Sample DOCM files to download
Free sample macro-enabled Word documents for testing upload filters, file-type detection, converters and macro scanners. None of them contains macros: each is a valid DOCM package without a VBA project, safe to open. Each was checked with unzip -t, by opening the package with python-docx, by converting it to PDF with LibreOffice, and with olevba.
Browsers can't show this kind of file in a page. Download it to open it in the app it belongs to.
What's inside sample-document.docm
Browsers can't preview DOCM files, so download it and open it in Word or LibreOffice, or rename a copy to .zip to see the parts. Word may still show a security bar, because the file type allows macros, but there is nothing to enable.
The macro-enabled content type
word/document.xmlis declared asapplication/vnd.ms-word.document.macroEnabled.main+xmlin[Content_Types].xml. That's what makes it a DOCM.No VBA project
There's no
vbaProject.binand novbaProjectrelationship.olevbareports "No VBA or XLM macros found".Document properties
Title, author, keywords and a comment saying the file contains no macros, in
docProps/core.xml.Headings, lists and a table
A table comparing the DOCX and DOCM content types, a numbered list of ways to check for macros, and a bulleted list.
Header and footer
A header line, and a footer with a PAGE field and the address of this page.
All sample DOCM files
Sample DOCM document (no macros)
sample-document.docm · 36.5 KB (37,389 bytes)
A one-page document made with python-docx, then given the macro-enabled content type. Properties, headings, a table, lists, a header and a footer field. No VBA project.
- Testing upload filters and previews with a real DOCM
- Checking that a macro scanner reports a clean file
Minimal DOCM, three parts
sample-minimal.docm · 1.0 KB (1,068 bytes)
The same three parts as
sample-minimal.docxon the DOCX page, written by hand. Its[Content_Types].xmldiffers from the DOCX one in one line only: the main part's content type. It's the file shown in the anatomy above.- Diffing the DOCX and DOCM content types
- Parser tests: the smallest valid DOCM
Mismatch test: DOCX content, .docm name
sample-content-type-mismatch.docm · 1.1 KB (1,088 bytes)
A minimal DOCX package (main part with the ordinary DOCX content type) saved under a
.docmname. Word should refuse to open it, because the extension and the content type disagree. No macros.- Testing detectors that compare content with extension
- Checking how your app reports a mismatched file
100 KB DOCM file
sample-100kb.docm · 100 KB (102,400 bytes)
The featured document, padded to exactly 102,400 bytes with whitespace inside
docProps/app.xml, stored uncompressed. No macros.- Upload and size-limit tests with a macro-enabled type
- Checking that filters handle the type, not just the size
Ways to test with them
- Upload filters: if your service blocks macro-enabled documents, all four files should be caught by type, even though none contains macros. If you only want to block files that really have macros, they should all pass.
- Content sniffing:
sample-content-type-mismatch.docmhas the DOCX content type under a.docmname. A detector that reads[Content_Types].xmlshould report DOCX; one that trusts the name says DOCM. - Macro scanners:
olevbaand similar tools should report no VBA on every file. A scanner that flags them is reacting to the extension or content type, not to code. - Diff the packages:
unzip -p sample-minimal.docm "[Content_Types].xml"and the same forsample-minimal.docxfrom the DOCX page differ in exactly one line. - Size limits:
sample-100kb.docmis exactly 102,400 bytes, for testing a limit at the boundary.
Free to use for testing, teaching and demos, commercially or not, with no attribution needed. A link back to this page is always appreciated.
Put it online
Have a DOCM file? Give it a link.
Drop a macro-enabled Word document on 99helpers and it gets its own link. Browsers can't display DOCM files, so visitors download it, and Word on Windows blocks its macros because it came from the internet; if readers don't need the macros, share a DOCX or PDF instead.
Questions
DOCM files, frequently asked
What is a DOCM file?
A Microsoft Word document that can contain VBA macros. It's built like a DOCX, a ZIP package of XML, with a different content type for the main part and an optional VBA project inside.
What's the difference between DOCX and DOCM?
Only macros. A DOCM can hold a VBA project and a DOCX can't. Otherwise the formats are the same, down to the XML.
Is a DOCM file dangerous?
It can be, because macros are programs. A DOCM from an unknown sender is a common malware trick. Office on Windows blocks macros in files from the internet, but don't enable content in a document you didn't expect.
Can I just rename a DOCM to DOCX to remove the macros?
No. Word checks that the extension matches the content type inside, so it refuses the renamed file, and the macros are still in it. Open it in Word and save it as a Word Document (.docx) instead.
How do I enable macros in a DOCM file?
For a file you made, choose Enable Content on the yellow bar. For a file from the internet, Office blocks them: if you trust it, right-click the file, choose Properties and tick Unblock, then open it again.
How can I see if a DOCM contains macros without opening it?
List its contents with unzip -l and look for vbaProject.bin, or run olevba from oletools, which extracts and analyses the VBA code without running it.
How do I open a DOCM file without Word?
LibreOffice Writer opens it on Windows, Mac and Linux, and Word for the web opens it in a browser without running the macros. Neither runs Word VBA the way desktop Word does.
Does a DOCM always contain macros?
No. The extension means the file may contain macros. Our samples are DOCM files with no VBA project.
Related formats
Other file types explained
Keep going
Related
Sources
- Microsoft [MS-OFFMACRO2]: Office Macro-Enabled File Format Version 2
- Microsoft [MS-OVBA]: Office VBA File Format Structure
- Microsoft Learn: Convert a document from DOCM to DOCX (Open XML SDK)
- Microsoft Learn: Macros from the internet are blocked by default in Office
- Cisco Talos: Macro Intruders, sneaking past Office defenses (2016)
- oletools (olevba, mraptor) on GitHub
Last reviewed 27 October 2026.