Excel Macro-Enabled File Type: .XLSM Explained

VBA & macros · Updated November 12, 2026

The standard Excel macro-enabled workbook file type is .xlsm. It can store a workbook’s worksheets and VBA macro code together; use it when you need to keep Excel macros in a modern workbook rather than remove them by saving as .xlsx.

What the .xlsm extension means

An .xlsm file is an Excel Macro-Enabled Workbook. Microsoft introduced this format with the Office Open XML file formats used by Excel 2007 and later. The extension signals that the workbook may contain VBA (Visual Basic for Applications) code, such as a macro that formats a report or automates a repetitive task.

The word “may” matters: an .xlsm workbook does not necessarily contain any macros. It can simply be a workbook saved in a format that permits them. Nor does the extension mean its macros will run automatically. Excel’s security settings, the file’s source, and the user’s permissions all affect whether VBA can run.

For most people asking which format to choose for a workbook that uses VBA, .xlsm is the direct answer. It retains macro capability while keeping the workbook in Excel’s modern workbook format. It is different from an ordinary .xlsx workbook, which cannot store a VBA project.

What an .xlsm file can contain

An .xlsm workbook can include the usual spreadsheet content—worksheets, formulas, charts, formatting, and other workbook features—along with a VBA project. That project may include procedures, modules, and workbook or worksheet event code. For example, a macro might run when someone clicks a button, or an event procedure might respond when a cell changes.

In the Open XML file structure, the VBA project is stored as a separate binary component within the workbook package. That is why changing a file’s name from .xlsx to .xlsm in File Explorer does not add macro capability or create working VBA code. The actual contents and format must be saved by Excel in the appropriate file type.

A workbook can also contain controls or other features that interact with macros. Their availability can depend on the Excel version and operating system. The file extension tells you the workbook is allowed to contain VBA; it does not guarantee that every feature will behave identically on every computer.

How to save a workbook as .xlsm

In Excel for Microsoft 365 on Windows, use File > Save As > Browse. In the Save As dialog, open the Save as type list, choose Excel Macro-Enabled Workbook (*.xlsm), select a folder, and save. If you are already working in an .xlsm file, saving normally keeps that format.

On a Mac, use File > Save As and select the Excel Macro-Enabled Workbook format in the file-format options. Names and dialog layout can vary slightly by Excel version. Excel for the web can open many macro-enabled workbooks, but it cannot create, edit, or run VBA macros; use the desktop app for those tasks.

If the workbook already contains VBA and you save it as .xlsx, Excel warns that the macro project cannot be retained in that format. Choosing to continue without the macro features removes the VBA project from the saved .xlsx copy. Keep an .xlsm copy if you may need that code later. Renaming the extension manually is not a substitute for Save As.

.xlsm compared with related Excel formats

Several Excel extensions can be associated with macros, but they serve different purposes. Choose based on what the file is meant to do, not just on which extensions can hold code.

  • .xlsx: The standard modern workbook format for workbooks without a stored VBA project. It is usually the right choice for ordinary spreadsheets that do not need VBA.
  • .xlsm: A macro-enabled workbook intended to hold workbook data and VBA code. It is the common choice for a macro-enabled spreadsheet shared as a workbook.
  • .xlsb: An Excel Binary Workbook. It can also contain VBA, but stores workbook data in a binary format rather than the .xlsm Open XML workbook format. It may be useful for certain large or performance-sensitive workbooks, but it is not automatically better or safer.
  • .xlam: An Excel add-in format. Use it when distributing VBA functionality as an add-in that can be loaded into Excel, rather than as a regular workbook users open to work with its sheets.
  • .xltm: A macro-enabled Excel template. It is designed as a starting point for new workbooks and can retain VBA in the template.
  • .xls: The older Excel 97–2003 workbook format. It can contain macros, but it is a legacy format with older limits and compatibility considerations.

For example, a team’s monthly workbook with a button that builds a summary is commonly saved as .xlsm. A reusable macro tool intended to be loaded into Excel may be distributed as .xlam instead. A template that creates new macro-enabled workbooks may use .xltm.

How to choose the right format

Start with the workbook’s purpose and the people who must use it. If there is no VBA and no requirement to preserve a VBA project, .xlsx is generally the simpler, more compatible choice. If the workbook depends on VBA, save it as .xlsm and tell recipients that the code is part of its workflow.

Consider these practical factors before choosing:

  • Does the workbook need VBA? If yes, use a format that supports it, such as .xlsm for a regular workbook.
  • Where will it be opened? Desktop Excel is needed to run VBA. People using Excel for the web can view or edit many workbook contents, but cannot execute the VBA macros there.
  • Who needs the code? A workbook is convenient when users need its worksheets and automation together. An add-in may make more sense for reusable functionality across workbooks.
  • Does the recipient trust the source? Recipients may see security warnings or have macros blocked by policy. Confirm that the intended workflow is permitted before relying on automation.

Saving as .xlsm does not make a workbook inherently more powerful, and saving as .xlsx does not remove every kind of automation from an organization’s environment. It specifically determines whether the workbook can retain a VBA project. Office Scripts and other tools are separate technologies with their own availability and storage arrangements.

Macro safety and security warnings

VBA macros can make changes, run commands, or interact with files and other applications. A malicious macro could misuse those abilities, so do not enable code simply because a workbook has an .xlsm extension or appears to come from a familiar contact. Unexpected attachments and files from unverified download sites deserve particular caution.

Excel may open a downloaded file in Protected View or block macros based on where the file came from and the organization’s security policy. In Microsoft 365 for Windows, macro controls are available through File > Options > Trust Center > Trust Center Settings > Macro Settings. Options and labels can vary by Excel build and organizational policy. Avoid enabling all macros globally just to make one file work; a broad setting can expose other workbooks to risk.

Safer checks include confirming the file’s source through a separate trusted channel, asking what the macro is supposed to do, and using code signed by a publisher you trust where appropriate. A digital signature helps identify the publisher and whether signed code has changed, but it does not prove that the code is harmless. Trusted Locations should be limited to folders you control, not used as a way to bypass warnings for arbitrary downloads.

If you do not need the macros, do not enable them. You may be able to inspect or work with the workbook’s non-macro content with code disabled, depending on its features and your security settings. If the file is part of a work process, follow your organization’s IT guidance rather than changing protected settings yourself.

Compatibility across Windows, Mac, and the web

The .xlsm format is supported by desktop versions of Excel for Windows and Mac, but VBA compatibility is not identical across platforms. Code that uses Windows-specific features, such as certain Windows API calls or ActiveX controls, may not work on a Mac. A macro that uses ordinary Excel object-model features may be more portable, but should still be checked in the environments where it will run.

Excel for the web does not run, create, or edit VBA macros. A macro-enabled workbook can often be opened there for other spreadsheet work, and its VBA project can remain in the workbook, but users must open it in desktop Excel to run the code. Some workbook features may also be unavailable or behave differently in the browser.

Compatibility also depends on how a macro is written. Code can refer to a worksheet by name, rely on a particular folder path, or expect a certain control to exist. If a workbook will be shared across operating systems or opened by several Excel versions, document the requirements and test the workflow on those systems before relying on it.

Common .xlsm problems and fixes

A frequent problem is that macros seem to disappear after someone saves a copy as .xlsx. The fix is to return to the original .xlsm file or a backup; changing the extension back cannot restore a VBA project that was removed during conversion. Another common confusion is receiving a security warning and assuming the workbook is broken. The warning may simply mean Excel has not trusted the file’s code.

When a macro does not run, check the situation before changing global security settings:

  • Confirm the file is actually saved as .xlsm or another suitable macro-capable format, rather than .xlsx.
  • Open it in desktop Excel, not Excel for the web, if the task requires VBA.
  • Check whether the file came from an untrusted location, is in Protected View, or is subject to an organization policy.
  • Verify that the macro exists and that the workbook’s buttons, event code, or instructions point to the correct procedure.
  • Ask the workbook’s author or your IT administrator about required controls, references, or operating-system-specific code.

Also remember that VBA changes are not undone with Ctrl+Z. Before running a macro that edits cells or files, save a separate copy of the workbook and understand what the code is intended to change.

Frequently Asked Questions

What is the Excel macro-enabled file extension?
The standard extension for a macro-enabled Excel workbook is .xlsm. It can store both workbook content and a VBA project.

Can an .xlsx file contain macros?
An .xlsx file cannot retain an embedded VBA project. If you save a macro-enabled workbook as .xlsx, Excel warns that the macros will be removed from that saved copy.

Does .xlsm mean macros run automatically?
No. The extension permits VBA code, but Excel’s security controls and the file’s trust status determine whether macros can run. A workbook can also use .xlsm without containing any macros.

Can I open an .xlsm file in Excel for the web?
Excel for the web can open many .xlsm workbooks, but it cannot run, create, or edit VBA macros. Use desktop Excel when the workbook’s VBA automation is needed.

Is .xlsm the same as .xlsb?
No. Both formats can support VBA, but .xlsm is an Open XML macro-enabled workbook and .xlsb is a binary workbook format. They are different file types and should be chosen for the workbook’s needs and compatibility requirements.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.