How to Fix Excel Not Saving or Running Macros
Question details
The user is unable to save or execute macros (VBA code) in their Excel workbook.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Saving an Excel workbook with custom VBA code or attempting to run an existing macro.
- Observed behavior
- Macros are lost after saving and reopening the document, or VBA code fails to execute because standard workbook formats do not retain them.
Ensure you have the original VBA code available in case it was stripped during a previous save. Also, verify that your organization's security policies allow the execution of macros.
Save the File as an Excel Macro-Enabled Workbook (.xlsm)
Excel's default .xlsx format cannot store VBA macros. You must use the .xlsm format to retain your code upon saving.
By default, Excel saves files in the .xlsx format, which is a macro-free format. If you write VBA code and save the file as an .xlsx, Excel will automatically remove the macros to maintain security standards. Saving as an .xlsm file is required to keep your macros functional.
Click on 'File' in the top-left corner of Excel, then select 'Save As' from the menu.
Click on the 'Save as type' drop-down menu and choose 'Excel Macro-Enabled Workbook (*.xlsm)' instead of the standard Excel Workbook.
Select your desired destination folder and click 'Save'. Your VBA code is now securely stored in the workbook.

Enable Macros in Excel Trust Center Settings
Even if a file is saved correctly, Excel might block macros from running for security reasons. You may need to enable them manually.
Create and Save Macro-Enabled Workbooks in WPS Office
WPS Office provides an intuitive spreadsheet tool that seamlessly supports saving and managing Macro-Enabled Workbooks. You can easily keep your VBA scripts intact without encountering format compatibility issues.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your spreadsheet containing the macro.
- 2. Go to Save As: Click on 'Menu' in the top-left corner and select 'Save As'.
- 3. Select XLSM format: In the 'File Type' dropdown, select 'Microsoft Excel Macro-Enabled Workbook (*.xlsm)'.
- 4. Save your work: Click 'Save' to retain your macros safely within the WPS Spreadsheet application.

Frequently Asked Questions
Why does my macro disappear after saving my Excel file?
If you save your file in the default .xlsx format, Excel automatically removes any VBA code to prevent macro-based viruses. You must explicitly save the file as a Macro-Enabled Workbook (.xlsm) to keep your macros intact.
Can I run macros in an .xlsx file?
No, the standard .xlsx file format cannot execute or store macros. To run macros, the code must be stored in supported macro-enabled formats like .xlsm, .xlsb, or the older .xls format.
Why is the macro button greyed out in my Excel workbook?
This usually happens if macros are disabled in your Trust Center settings, if the file is opened in Protected View, or if the current file format strips the macro content.




