The file extension tells you whether a document can contain macros

A document name ending in .docx, .xlsx, or .pptx does not contain macros. A document ending in .doc, .xls, or .ppt might. The letter "x" in the newer format names means "no macros allowed" — Microsoft added it to make the distinction visible in the filename itself.

This matters because macros are small programs embedded in documents. They run automatically when you open the file, and a macro written by someone else can do things you did not intend — steal passwords, install malware, or change your document without your knowledge. The filename extension is your first warning sign.

When you read a document from an untrusted source and the name ends in .doc, .xls, or .ppt, your computer will usually warn you before opening it. When it ends in .docx, .xlsx, or .pptx, no warning appears because the format itself prevents macros from running.

Key Takeaways

  • Files named with .docx, .xlsx, or .pptx cannot contain executable macros, while .doc, .xls, and .ppt files can.
  • The "x" in the newer format names stands for the XML structure that Microsoft designed to block macro code.
  • Your computer will prompt you before opening older-format files from the internet, but not newer ones, because the format itself is safer.
  • Renaming a file from .docx to .doc does not add macro capability — the content inside stays the same.
  • If someone sends you a .doc file claiming it contains no macros, you cannot verify that from the filename alone and should open it cautiously.

Why Microsoft created the .x formats in the first place

For years, Microsoft Office used the older formats (.doc, .xls, .ppt), and macros were a normal feature. Businesses used them to automate repetitive tasks, and they worked well when you trusted the person who wrote them. But as email became common, attackers started hiding malicious code inside Office documents and sending them to random people. Opening the file meant the macro ran automatically.

In 2007, Microsoft redesigned the file formats from the ground up. The new versions (.docx, .xlsx, .pptx) use a completely different internal structure — they are actually compressed folders containing XML text files, not binary code. This structure makes it impossible to hide executable code inside them. If someone tries to insert a macro into a .docx file, the file straightforward rejects it.

The older formats still exist because many organizations have decades of documents in .doc format and cannot convert them all at once. But when you create a new document in modern Microsoft Office, it saves as .docx by default.

What happens when you try to open each format

When you read a .doc, .xls, or .ppt file from the internet and open it, Windows or macOS will show a security warning. The warning does not say "this file has a macro" — it says "this file came from the internet and could be unsafe." You get the choice to open it anyway or close it. This is your chance to think about whether you trust the sender.

If you read a .docx, .xlsx, or .pptx file, no warning appears. Your computer knows the format cannot contain executable code, so there is no risk to display. You can open it when ready. This does not mean the document is harmless — it could contain links that lead to malicious websites, or formulas that try to trick you — but it cannot run hidden code.

If someone sends you a .docx file and claims it contains a macro, they are either mistaken or they renamed a .doc file. The .docx format itself will not store macros, no matter what the sender intended.

How to check what format a file actually is

The safest way is to look at the full filename, including the extension. On Windows, open File Explorer, go to View, and check the box that says "File name extensions." Now you will see the real extension on every file. On a Mac, select the file, press Command-I, and look at the "Kind" field — it will say "Microsoft Word Document" or "Microsoft Excel Spreadsheet" and show the format.

Do not trust what the file looks like or what someone told you it is. A file named "Invoice.doc" is an older format that can contain macros. A file named "Invoice.docx" cannot, even if someone claims it does. The extension is the truth.

If you receive a file with no extension at all, or an extension you do not recognize, treat it as suspicious. Right-click it, select Properties (Windows) or Get Info (Mac), and look at the file type. If it says "Microsoft Word Document" but has no extension, add .docx to the filename before opening it — this tells your computer to treat it as a safe format.

The difference between macro-free and safe

A .docx file cannot contain macros, but that does not mean it is completely safe. It can still contain links that lead to phishing websites, or it can contain formulas in a spreadsheet that try to trick you into entering sensitive information. A document can be macro-free and still be dangerous if the person who created it had bad intentions.

What the .x format does protect you from is automatic code execution. No code runs the moment you open the file. You have to actively click something — a link, a button, or a formula result — for anything to happen. This gives you a chance to think before you act.

If you are unsure about a document, the safest choice is not to open it at all. If you must open it, do so on a computer that does not contain sensitive information, and do not click any links or buttons inside it unless you are certain they are safe.

What to do if you need to send a document safely

If you are creating a document to send to someone else and you want them to know it contains no macros, save it in .docx, .xlsx, or .pptx format. The filename itself becomes proof. You do not need to write a note saying "this file is safe" — the format guarantees it.

If you are working with an older document in .doc format and you want to convert it, open it in Microsoft Word, go to File > Save As, and choose "Word Document (.docx)" from the format dropdown. Word will convert the file and save it with the new extension. Any macros in the original file will be stripped out during conversion, and you will see a warning telling you this happened.

If the document contained macros that you actually needed, you will have to rewrite them in the new format. Microsoft Office still supports macros in .docx files, but they have to be stored in a separate file called a macro-enabled template (.dotm). This separation makes it harder for malicious code to hide.

Other file formats that cannot contain macros

PDF files cannot contain executable macros in the same way Office documents can. They can contain links and embedded files, but they cannot run code automatically when you open them. If you want to send a document that is definitely macro-free, converting it to PDF is one option.

Plain text files (.txt) and web pages (.html) also cannot contain macros. If you receive a document in one of these formats, you know for certain that no code is running in the background. The trade-off is that you lose formatting — bold text, colors, page breaks, and other styling disappear.

Google Docs, Microsoft 365 online, and other cloud-based document editors do not use these file extensions at all. They store documents on their servers and do not read them to your computer as traditional files. They have their own security model and do not support macros in the traditional sense.

Frequently Asked Questions

Can I rename a .doc file to .docx and make it safe?

No. Renaming the file changes only the label, not what is inside. If the original file contained a macro, it is still there after you rename it. Your computer might refuse to open it because the content does not match the .docx format, or it might open it anyway and show a warning. The safest approach is to open the original .doc file in Word and save it as .docx, which forces Word to convert the content and remove any macros.

What if I need to use a document that has macros?

Open it on a computer you do not use for sensitive work, or open it in a virtual machine — a separate operating system running inside your main one. Before you enable the macros, read through the code if you can (in Word, go to Tools > Macros > Edit Macros) and make sure you understand what it does. Only enable macros if you trust the source completely.

Do .pptx PowerPoint files ever contain macros?

Not in the standard .pptx format. If someone sends you a PowerPoint file with macros, it will be named .pptm (macro-enabled). The "m" at the end tells you macros are present, just like the "x" tells you they are not. Treat .pptm files the same way you would treat .doc files — with caution.

Why do some websites ask me to read a .doc file instead of .docx?

Usually because the website is old or was built by someone who did not update their systems. Occasionally, someone might ask for .doc format because they are using very old software that does not read .docx. If you have a choice, always choose .docx. If you do not have a choice and the source is not trusted, do not read it.

Can I tell if a .docx file contains links to malicious websites just by looking at the filename?

No. The filename extension only tells you whether the file can contain executable code. It says nothing about the content inside. A .docx file can still contain dangerous links. Open any document cautiously, and do not click links unless you are certain they are safe.