VBA & Macro Problems

How to Save an Excel Macro-Enabled Template as an XLSM Workbook on Mac

Bushra ParveenBushra Parveen Oct 29, 2026 870 views

Question details

The user needs to save an Excel macro-enabled template or existing file as an XLSM workbook on Mac using VBA without losing macros.

How to Save an Excel Macro-Enabled Template as an XLSM Workbook on Mac
Product
Excel
Device & OS
Mac
Scenario
Using the VBA SaveAs method to convert or save a macro-enabled file on a Mac.
Observed behavior
If the correct FileFormat value is not specified during the SaveAs process, Excel defaults to saving a macro-free workbook, causing the VBA project to be stripped or triggering an error.
Before you start

Ensure your Excel Developer tab is enabled and that you have securely backed up your original macro-enabled template before testing new VBA scripts.

Solution 1Recommended

Specify the Correct FileFormat for XLSM Workbooks in VBA

Use the appropriate FileFormat enumeration in your VBA script to ensure the workbook retains its macros when saved on a Mac.

When saving a macro-enabled file via VBA on a Mac, you must explicitly declare the file format in your code. For a macro-enabled workbook (.xlsm), the required FileFormat value is 52. Omitting this parameter often defaults the save process to a standard macro-free format (.xlsx), which strips your code.

1
Open the VBA Editor

Press 'Option + F11' on your Mac keyboard or navigate to the Developer tab and click 'Visual Basic' to launch the editor.

2
Locate your SaveAs Script

Find the module or macro containing the SaveAs method that you are using to save your template.

3
Modify the SaveAs Code

Update your code to include the FileFormat parameter explicitly. Modify your script to look like this: ActiveWorkbook.SaveAs Filename:="YourFilePath.xlsm", FileFormat:=52

4
Run and Verify

Execute the macro and navigate to your saved location. Open the newly created .xlsm file to confirm the macros are preserved and functioning.

Specify the Correct FileFormat for XLSM Workbooks in VBA
Mac Excel FileFormat Values: FileFormat 52 is exclusively used for .xlsm files. If you need to save your file as an Excel binary (.xlsb), use FileFormat 50 instead.
Free Microsoft Office alternative

Experience Seamless Spreadsheet Management with WPS Office

If you are encountering frustrating formatting or macro errors in Microsoft Excel for Mac, consider switching to WPS Office. It provides a lightweight, highly compatible, and user-friendly environment for your daily spreadsheet tasks without the hefty subscription fees.

  1. 1. Download the Installer: Visit the official WPS Office website and download the free version for Mac.
  2. 2. Install WPS Office: Follow the simple on-screen instructions to install the application on your device.
  3. 3. Open Your Spreadsheets: Launch WPS Spreadsheets and open your existing Excel files to enjoy seamless compatibility.
Highly compatible with Microsoft Excel formats including .xlsx, .xlsm, and .csvFree and lightweight alternative to Microsoft OfficeFamiliar user interface ensuring a zero learning curveBuilt-in PDF editing and powerful cloud collaboration tools
microsoft office alternative - wps office

Frequently Asked Questions

What is the FileFormat value for saving an XLSM file in VBA?

In Excel VBA, the correct FileFormat value for a macro-enabled workbook (.xlsm) is 52. Explicitly setting this value ensures that your macros are not stripped out when the file is saved.

Why did my macro disappear after saving the template on Mac?

If you saved the template without explicitly specifying a macro-enabled format in your VBA code, Excel defaults to saving it as a standard macro-free workbook (.xlsx). This action permanently removes any contained VBA code.

Can I save a macro-enabled template (.xltm) as a standard workbook?

Yes, you can. However, if you save it as a standard workbook (.xlsx, using FileFormat 51), any VBA macros contained in the template will be permanently removed. To retain the macros, it must be saved as an .xlsm file.