The standard Excel macro-enabled workbook extension is .xlsm. Use it when saving a workbook that contains VBA macros; other formats, including .xlsb, .xltm, and the older .xls, can also store macros for specific purposes.
What an Excel macro extension means
A file extension is the letters after the final period in a filename, such as QuarterlyReport.xlsm. It tells Windows and Excel what kind of file it is and how to handle it. A macro is a set of instructions that can automate tasks in Excel, commonly written in Visual Basic for Applications (VBA). The extension identifies a file format capable of keeping that macro code; it does not mean a macro is present, enabled, or safe to run.
For an ordinary Excel workbook with VBA, .xlsm is the clearest and most widely recognized choice. It is the macro-enabled counterpart to .xlsx. The distinction matters when saving: .xlsx is designed for workbooks without VBA projects, while .xlsm can preserve them. Renaming an .xlsx file to end in .xlsm does not convert it or add macro support. Use Excel’s Save As command to change formats properly.
Excel file formats that can contain macros
Excel has several formats that can retain VBA, but they are not interchangeable in every situation. Choose based on how the workbook will be used and shared.
- .xlsm — Excel Macro-Enabled Workbook: The usual choice for a workbook with macros. It retains VBA while using the modern Excel workbook format.
- .xlsb — Excel Binary Workbook: A binary workbook that can contain VBA. It can be useful for large or complex workbooks, but some people and systems expect the more familiar .xlsm extension. Check compatibility with the people and tools receiving the file.
- .xltm — Excel Macro-Enabled Template: Use this for a reusable template containing VBA. Opening the template normally creates a new workbook based on it, rather than simply opening the template as an ordinary working file.
- .xls — Excel 97–2003 Workbook: The older binary workbook format can store macros. It may be needed for an older system, but it has legacy limits and is generally not the best default for a new workbook.
- .xlam — Excel Add-In: This format is intended for Excel add-ins, which can provide reusable features or functions. It is not the typical format for a workbook that users open and edit as a report.
Older Excel add-ins may use .xla. If a workplace tool supplies an add-in, follow its installation instructions rather than changing its extension yourself.
How to save a workbook as .xlsm
In Excel for Microsoft 365 on Windows, use these steps to save a macro-capable workbook:
- Open the workbook and choose File > Save As.
- Select Browse if needed to choose a folder and open the full Save As dialog.
- In the Save as type list, choose Excel Macro-Enabled Workbook (*.xlsm).
- Enter a filename, check the folder and format, and select Save.
If you are working with an existing workbook that already contains VBA, make a separate copy before changing its format. After saving, check the filename ending and, if the project is important, reopen the saved copy and confirm that its VBA project is still present. Excel may display a format compatibility or macro warning; read it before confirming, because choosing a format that does not support VBA can remove the code.
On Excel for Mac, use File > Save As, then select the appropriate format from the File Format menu. The wording and dialog layout can differ from Windows. Excel for the web does not provide the full VBA editing or execution environment, so use the desktop app when you need to create, edit, or run VBA macros.
Choosing between .xlsm, .xlsb, and .xltm
For a macro-enabled workbook shared with colleagues, .xlsm is usually the practical default: its purpose is obvious, and it fits common Excel workflows. Choose .xlsb when you have a reason to use a binary workbook, such as working with a particularly large file, and have confirmed that recipients and connected systems can handle it. A smaller file or faster opening is not guaranteed in every workbook, so test the actual file rather than assuming the extension will solve performance problems.
Choose .xltm when the file is meant to be a starting point for repeated work. For example, a team might distribute a monthly reporting template with a button that prepares a standard report. Keeping the master as a template helps distinguish the reusable source from each month’s completed workbook. If users are meant to edit one shared data file directly, a regular .xlsm workbook is usually a better fit.
Use .xls only when an older application or process specifically requires that format. Saving to it can trigger compatibility warnings because it predates many modern Excel features. An add-in developer or administrator may choose .xlam for a centrally distributed tool, but ordinary workbook users generally should not convert their workbooks to an add-in format.
Why .xlsx cannot keep VBA macros
The common misconception is that any Excel file can keep a macro as long as it opens in Excel. In fact, .xlsx is a macro-free workbook format. If you save a workbook containing VBA as .xlsx, Excel warns that the VBA project cannot be saved in that format. If you proceed, the workbook’s VBA code is removed from the saved .xlsx copy.
That does not mean every .xlsx file is dangerous or that it cannot contain other kinds of automation. It means the format does not store a VBA project. Excel features such as formulas, formatting, and many built-in tools can still be used in .xlsx files. If someone sends you a macro-enabled workbook and you only need its data, you can save a separate .xlsx copy after reviewing the warning. Keep the original .xlsm if the macros may be needed later.
Changing the filename extension in File Explorer is not a safe conversion method. It changes the name, not the internal file structure, and may cause Excel to report that the file format and extension do not match. Use File > Save As and select the intended format instead.
Macro security and sharing files
A macro-enabled extension allows VBA to be stored; it does not automatically authorize the code to run. Excel’s macro security controls, organizational policies, and the file’s source can affect whether macros run. A workbook from an unknown sender could contain code that changes files, accesses information, or performs other unwanted actions. Do not enable macros simply because a workbook asks you to.
Before enabling code, verify who sent the file and why the automation is needed. If it came from a colleague, confirm through a trusted channel that they intended to send a macro-enabled workbook. When possible, ask for an explanation of what the macros do or have your organization’s IT team review the file. Excel may show a security notice or open a downloaded file in a restricted state; the exact behavior depends on the source of the file and the computer’s security policies.
For administrators and experienced users, Windows Excel has macro-related controls under File > Options > Trust Center > Trust Center Settings. Do not treat changing a security setting to allow all macros as a routine fix. Company-managed settings may override individual choices, and an IT administrator should guide changes on a work device. A trusted document still deserves ordinary care: macros can be changed, and a previously safe file can be replaced or altered.
Common extension problems and fixes
- The macro disappeared after saving: Check whether the file was saved as .xlsx. If so, return to the original macro-enabled copy or a backup; changing the extension afterward will not restore deleted VBA.
- Excel says the format and extension do not match: The filename may have been renamed without converting the file, or it may be damaged. Open it only if you trust its source, then use Save As to select the correct format.
- The workbook opens but its macros do not run: The code may be blocked by security settings, organizational policy, or a warning that has not been addressed. Confirm the source and consult your administrator rather than lowering security indiscriminately.
- A recipient cannot use the workbook: They may be opening it in Excel for the web, using software with limited VBA support, or working under a policy that blocks macros. Ask what app and device they use, then provide a suitable workflow or a non-macro copy if appropriate.
- The file has an unexpected extension: Check the full filename and the selected format in Excel. Windows can hide known file extensions in File Explorer, making a filename appear to end differently than it does.
If VBA code is digitally signed, editing the code can invalidate that signature. Recipients may then see a different trust status. This is another reason to coordinate changes to shared macro workbooks and, where an organization uses signing, follow its code-signing process.
Using macro-enabled workbooks on Mac and the web
Excel for Mac supports VBA macros, although some Windows-specific automation, external integrations, or operating-system features may not behave the same way on a Mac. A workbook can therefore have the correct .xlsm extension and still rely on code that needs adjustment for another platform. If a workbook is used across Windows and Mac, test its actual macro tasks on both systems.
Excel for the web can open many macro-enabled workbooks and preserve the file, but it cannot create, edit, or run VBA macros. A user may be able to work with the workbook’s cells in a browser while the VBA automation remains unavailable. For a process that depends on a button or macro, open the workbook in the desktop version of Excel on a supported computer. Do not assume that seeing a workbook in a browser means its VBA code is running.
Frequently Asked Questions
What is the extension for an Excel macro file?
The standard extension is .xlsm, short for Excel Macro-Enabled Workbook. Excel also supports VBA in formats such as .xlsb, .xltm, .xls, and .xlam, each intended for different uses.
Can I save a macro-enabled workbook as .xlsx?
You can save a copy as .xlsx, but that format cannot retain the VBA project. Excel warns that the macros will be removed if you continue. Keep an .xlsm copy if you need the code.
Does an .xlsm file run macros automatically?
No. The extension means the file format can contain VBA; it does not guarantee that macros will run. Excel security settings, file origin, and organization policies can block or require approval for macros.
What is the difference between .xlsm and .xlsb?
Both can store VBA. .xlsm is the standard macro-enabled workbook format and is easy to recognize, while .xlsb is a binary workbook format that may suit some large or complex files. Check compatibility before sharing .xlsb files.
Can Excel for the web run VBA macros?
No. Excel for the web can open and work with many macro-enabled workbooks, but VBA macros cannot be created, edited, or run in the browser. Use desktop Excel for those tasks.
Related
- Protect Sheet in Excel: Allow Editing Specific Cells
- Excel Conditional Formatting Icon Sets Explained
- Markdown Table Merge Cells? What You Can Do
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- VBA Loop Through a Dictionary: Keys, Items, and ExamplesTo loop through a VBA Dictionary, use For Each key In dict.Keys, then read each value with dict(key).…
- Fortify Macro Recorder: Does Fortify Record Macros?No: OpenText Fortify is an application-security product family, not a macro recorder, and its standard tools do not…
- VBA: Open a UserForm When a Command Button Is ClickedTo open an Excel VBA UserForm when a worksheet button is clicked, assign a public macro to a…
- Input Box in Excel VBA: Use InputBox and Get DataIn Excel VBA, use InputBox to ask for a text value, or Application.InputBox when you want to restrict…
- VBA Delete Row If Cell Contains TextTo delete rows when a cell contains particular text, use VBA’s InStr function in a loop that checks…
- Excel VBA: Find a Cell Containing a Specific Date ValueTo find a cell containing a specific date with Excel VBA, loop through the date column and compare…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.