The file extension tells you whether macros are present
When you save a document in Microsoft Word or Excel, the filename extension — those letters after the dot — shows whether the file can run macros. A file ending in .docx (Word) or .xlsx (Excel) does not contain macros. A file ending in .docm (Word) or .xlsm (Excel) does contain macros and can run them when you open the file.
This matters because macros are small programs embedded in documents. They can automate repetitive tasks, but they can also carry malware. Microsoft designed the filename system to make the difference visible at a glance — if you see the "m" in the extension, macros are present.
The same rule applies to other Office formats. PowerPoint files ending in .pptx have no macros; files ending in .pptm do. Access databases ending in .accdb have no macros; files ending in .accde do. Publisher files follow the same pattern: .pub means no macros, .pubm means macros are present.
Key Takeaways
- Word and Excel files ending in .docx and .xlsx do not contain macros; files ending in .docm and .xlsm do.
- The "m" in the extension stands for macro-enabled, so any Office file with an "m" before the final "x" or other letter contains macros.
- Microsoft uses this naming system so you can see whether a file can run code before you open it.
- Files saved in older Office formats like .doc and .xls can contain macros but do not signal this in the filename.
Why Microsoft changed the naming system
Before 2007, Microsoft Office used a single format for each program. A Word file was always .doc, an Excel file was always .xls. These formats could contain macros, but there was no way to tell from the filename alone whether a particular file had them. This created a security problem: you could not know whether opening a file would run hidden code.
Starting with Office 2007, Microsoft split each format into two versions. The standard version — .docx, .xlsx, .pptx — stores only the document content and formatting. The macro-enabled version — .docm, .xlsm, .pptm — can store macros as well. This way, the filename itself tells you what the file can do.
If you receive a file with an older extension like .doc or .xls, you cannot tell from the name whether it contains macros. You have to open it in the program and check the macro settings, or ask the person who sent it.
What happens when you open a macro-enabled file
When you open a .docm, .xlsm, or .pptm file, Microsoft Office shows a security warning at the top of the window. The warning says the file contains macros and asks whether you want to enable them. If you click "Enable Content," the macros run. If you click "Disable," the file opens but the macros do not run.
This warning appears because macros can do anything a person could do in the program — delete files, send emails, modify documents without your knowledge. A malicious macro could steal passwords or install software. By making the warning visible and requiring you to choose, Microsoft gives you a chance to decide whether to trust the file.
If you receive a .docx or .xlsx file, no warning appears because these formats cannot contain macros at all. The file is safe to open in that regard, though it could still contain other types of content — embedded objects, links to external websites — that pose different risks.
How to check a file's extension on your computer
On Windows, right-click the file and select "Properties." The filename appears at the top of the window, including the full extension. By default, Windows hides file extensions in the folder view, so you may need to look at the Properties window to see whether the file ends in .docx or .docm.
To make extensions visible in the folder view itself, open File Explorer and click the "View" tab at the top. Check the box next to "File name extensions." After that, you will see the full filename with extension for every file in every folder.
On Mac, click the file once to select it, then press Command+I to open the Info window. The filename appears near the top. Mac shows file extensions by default in most cases, so you should see the full name including the extension in the Finder window itself.
Converting between macro and non-macro formats
If you have a .docm file and want to remove the macros, you can save it as .docx instead. Open the file in Word, go to File > Save As, and choose "Word Document (*.docx)" from the file type dropdown. Word will save a copy without the macros. The original .docm file remains unchanged.
When you do this, Word warns you that the file contains macros and asks whether you want to keep them. If you choose to save as .docx, the macros are not copied to the new file. This is useful if someone sent you a macro-enabled file but you do not need the macros and want to reduce the security risk.
Going the other direction — converting .docx to .docm — does not add macros. It only changes the format so that macros could be added later. The file remains the same until someone actually writes and inserts a macro into it.
Older Office formats and macro confusion
Files saved in the older .doc format (Word 97-2003) can contain macros, but the filename does not signal this. When you open a .doc file in modern Word, the same security warning appears as with .docm files. The same applies to .xls (Excel 97-2003) and .ppt (PowerPoint 97-2003) files.
If you are working with older files, treat any .doc, .xls, or .ppt file as potentially containing macros. The filename does not tell you, so you have to rely on the security warning when you open the file. If you trust the source, enable the macros. If you do not, disable them.
Many organizations have stopped using these older formats because the filename ambiguity creates confusion and security risk. If you are creating new documents, use .docx, .xlsx, or .pptx unless you specifically need macros, in which case use the .docm, .xlsm, or .pptm versions.
Frequently Asked Questions
Can a .docx file ever contain macros?
No. The .docx format is designed to store only document content and formatting. If someone tries to insert a macro into a .docx file, Word removes it when you save. If you need macros, you must use .docm.
What if I see a file with a double extension like .docx.docm?
This usually means the file was renamed incorrectly or saved twice. The actual format is determined by the final extension — the one after the last dot. Right-click and check Properties to see what the system recognizes, or ask the person who sent it what format they intended.
Is it safe to open a .docm file?
It depends on the source. If the file came from someone you trust and you know they use macros for legitimate work, it is safe. If it came from an unknown sender or unexpected email, disable the macros when the warning appears. You can still read the document; the macros simply will not run.
Do I need to worry about macros in .xlsx files from my bank or accountant?
If the file ends in .xlsx, there are no macros to worry about — the format does not support them. If it ends in .xlsm, ask your bank or accountant what the macros do before you enable them. Legitimate financial institutions usually do not send macro-enabled files.
Can I rename a .docm file to .docx to remove the macros?
Renaming the file does not remove the macros — it only changes the label. The macros are still inside the file. To actually remove them, open the file in Word, save it as .docx using File > Save As, and choose the non-macro format from the dropdown.