XLSX vs XLSM: What Happens to Macros When You Save or Convert

November 08, 2026 · XLSX.now Editorial · XLSX Troubleshooting

Explain macro parts, extension/content mismatch, signatures and safe migration.

How the Extension and Internal Content Type Must Agree

Every Office Open XML workbook—whether .xlsx, .xlsm, or .xlsb—uses the ZIP-based package structure defined by the Open Packaging Conventions. The file extension signals to the host application what to expect, but the actual contents are declared inside the package in [Content_Types].xml. A mismatch between the extension and the declared content type is the root cause of most “corrupt file” errors and silently missing macros.

  • A valid .xlsx file must not contain a VBA project part. The [Content_Types].xml must omit any <Override> element for application/vnd.ms-office.vbaProject.
  • A valid .xlsm file must contain a VBA project part (typically stored as xl/vbaProject.bin) and must declare it in [Content_Types].xml with the content type application/vnd.ms-office.vbaProject.

When you rename a .xlsm to .xlsx without altering the package internals, Excel reads the .xlsx extension, expects a macro-free workbook, finds the VBA project part, and blocks the file as invalid. Renaming a .xlsx to .xlsm produces the opposite condition: the extension promises macros, but no VBA project part exists. Excel opens the file but reports that it contains no macros. These behaviors are specified by the Office Open XML standard; the authoritative content-type registry and extension rules are in the primary technical reference.

What Each Format Physically Contains

The visual layer—cells, charts, pivot tables, conditional formatting—is identical between .xlsx and .xlsm. The difference is confined to the VBA storage parts.

Package part .xlsx .xlsm
xl/workbook.xml Present Present
xl/vbaProject.bin Absent Present
xl/_rels/workbook.xml.rels No relationship to VBA project Contains a relationship of type http://schemas.microsoft.com/office/2006/relationships/vbaProject
[Content_Types].xml No VBA content type Includes <Override PartName="/xl/vbaProject.bin" ContentType="application/vnd.ms-office.vbaProject"/>

A viewer that does not implement VBA (Google Sheets, Apple Numbers, LibreOffice Calc without the VBA extension) will render the data but silently ignore xl/vbaProject.bin. The workbook opens without error, but no macro-driven automation executes.

Three Failure Modes with Diagnostic Steps

1. “The file is corrupt” After a Rename

A file originally saved as .xlsm is renamed to .xlsx to bypass an email filter or a file-size check. Excel opens the ZIP package, reads [Content_Types].xml, finds the VBA content type, and concludes the file violates the .xlsx specification.

Diagnostic step: Inspect the file with any ZIP utility. On macOS or Linux, run unzip -l renamed_file.xlsx | grep vbaProject. On Windows, open the file in 7-Zip and look for xl/vbaProject.bin. If the entry exists, the file is a misnamed .xlsm. Rename it back to .xlsm to restore normal operation. If you must deliver a .xlsx, remove the VBA project from the package first (see the migration steps below).

2. Macros Are Saved but Do Not Run

You save a workbook containing VBA code as .xlsx. Excel displays the warning: “The following features cannot be saved in a workbook without macro support: VB project.” If you click “Yes” to continue, Excel writes a .xlsx package with no VBA project part. The workbook looks intact, but the code is absent.

Diagnostic step: Open the saved .xlsx and press Alt+F11 to open the VBA editor. If the project explorer pane is empty, the macros were stripped during the save. You cannot recover them from the .xlsx file. The only recovery path is to locate a prior .xlsm version or a backup of the exported .bas files.

3. A .xlsm Opens in a Non-Excel Viewer Without Macros

This is expected behavior, not a failure. The VBA project is stored as a binary blob that only Excel and a limited set of compatible applications can parse. Google Sheets, Apple Numbers, and LibreOffice Calc (without the VBA extension) will render the data and formatting but ignore xl/vbaProject.bin. Any automation tied to buttons, event handlers, or custom functions will be absent.

Hard Limits of Conversion

  • No VBA project in the source: If the original file never contained macros, saving it as .xlsm produces a valid macro-enabled container with no code inside. The extension alone does not create macros.
  • Excel Online and mobile apps: Microsoft’s web and mobile Excel clients cannot create, edit, or persist VBA projects. Saving a workbook from those platforms as .xlsm may produce a file with a correct extension but no xl/vbaProject.bin part.
  • Third-party converters: Tools that change the extension or repack the ZIP without updating [Content_Types].xml and the relationship files produce broken files. Always verify the package contents after conversion using a ZIP listing.

Safe Migration: Moving Macros Without Breaking the File

From .xlsm to .xlsx (Remove Macros)

  1. Open the .xlsm file in the desktop version of Excel.
  2. Press Alt+F11 to open the VBA editor.
  3. In the Project Explorer, right-click each module, class, and userform and select Export File. Save each as a .bas, .cls, or .frm file for later reuse.
  4. Close the VBA editor. Go to File → Save As and choose Excel Workbook (.xlsx). Excel will warn that the VB project will be removed. Click Yes.
  5. Verify the result: inspect the new .xlsx with a ZIP utility. The entry xl/vbaProject.bin must be absent.

From .xlsx to .xlsm (Add Macros)

  1. Open the .xlsx file in the desktop version of Excel.
  2. Go to File → Save As and choose Excel Macro-Enabled Workbook (.xlsm). Excel adds the necessary content type and relationship scaffolding but does not yet create a VBA project.
  3. Press Alt+F11 to open the VBA editor. Add code directly or import previously exported .bas, .cls, and .frm files.
  4. Save the .xlsm file. Excel writes xl/vbaProject.bin and updates [Content_Types].xml.
  5. Verify the result: inspect the .xlsm with a ZIP utility. The entry xl/vbaProject.bin must be present.

Command-Line Verification Before Distribution

# Check if a .xlsx contains a VBA project (should return nothing)
unzip -l file.xlsx | grep vbaProject

# Check if a .xlsm is missing its VBA project (should return a line)
unzip -l file.xlsm | grep vbaProject

On Windows, open the file in 7-Zip and navigate to the xl folder. The presence or absence of vbaProject.bin reveals the actual format regardless of extension.

Handling a Mismatched File You Receive

If someone sends you a file where the extension and internal content disagree, you have three options:

  1. Rename to the correct extension. If a ZIP listing shows vbaProject.bin inside a .xlsx, rename it to .xlsm. If a .xlsm lacks vbaProject.bin, rename it to .xlsx. Excel will re-validate the file on the next open.
  2. Re-save from Excel. Open the file (Excel may warn of corruption; click Yes to attempt repair), then immediately use File → Save As and select the format that matches the internal content.
  3. Inspect the content type directly. Upload the file to xlsx.now and examine the raw [Content_Types].xml in the file structure viewer. If an <Override> element references vbaProject, the file is macro-enabled regardless of extension. You can download a corrected copy with the proper extension from the same tool.