How to Fix Cannot Run Macro Error in Macro-Enabled Excel Workbooks
Question details
The user needs to resolve an issue where Excel displays an error stating that a macro cannot run or is disabled, even though macros are enabled in the workbook settings.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Attempting to execute a macro by clicking an assigned button or shape in a macro-enabled workbook.
- Observed behavior
- Excel blocks the execution with an error indicating the macro cannot run or might be disabled, despite the workbook being saved in a macro-supporting format with macros enabled.
Ensure your file is explicitly saved as an Excel Macro-Enabled Workbook (.xlsm) and that you have enabled macros in the Excel Trust Center before modifying the VBA code.
Verify VBA Procedure and Reassign Macro Button
Check if the macro exists in the correct standard module, ensure it is public, and reassign it to the button to fix broken name references.
Often, this error occurs if the button is assigned to a macro name that was recently changed, deleted, or moved to a different module. If the macro is marked as Private or has compile errors, Excel will also fail to run it.
Press ALT + F11 on your keyboard to open the Visual Basic for Applications (VBA) Editor.
In the Project Explorer pane on the left, find the standard module containing your macro (for example, MDL_DM_00_Setup_Cmd) and double-click to open it.
Ensure your macro (e.g., 'btnclick') is present, declared as a 'Public Sub', and does not have any syntax errors. Go to Debug > Compile VBAProject to check for compile issues.
Return to your Excel worksheet. Right-click the button or shape that triggers the error and select 'Assign Macro' from the context menu.
Select the correct macro name from the list provided in the Assign Macro dialog box and click 'OK'. Test the button again.

Add Workbook Folder to Trusted Locations
Bypass strict macro security blocks by adding the folder where your .xlsm file is stored to Excel's Trusted Locations.
Easily Manage and Run Macros with WPS Office
WPS Office provides robust support for VBA and macro-enabled workbooks. You can easily enable, edit, and run macros in a highly compatible and secure spreadsheet environment.
- 1. Open Macro Workbook: Launch WPS Spreadsheet and open your .xlsm macro-enabled file.
- 2. Access Developer Tools: Navigate to the 'Developer' tab in the top ribbon to access macro settings.
- 3. Inspect VBA Code: Click 'Visual Basic' or 'Macros' to view your procedures, standard modules, and troubleshoot any broken code references.
- 4. Assign Macro to Objects: Right-click any shape or control button on your sheet and choose 'Assign Macro' to properly link your VBA scripts.

Frequently Asked Questions
Why does Excel say my macro is disabled when I already clicked Enable Content?
This commonly happens when a button is trying to run a macro that Excel cannot locate. If the macro was renamed, moved to a different standard module, deleted, or changed to Private, clicking the button triggers the generic 'macro cannot run' error.
Do I need to save my file as .xlsm to run macros?
Yes, standard Excel workbooks (.xlsx) automatically strip out all VBA code when saved. You must save the file as an Excel Macro-Enabled Workbook (.xlsm) or an Excel Binary Workbook (.xlsb) to retain and run macros.
How do I check for compile errors in my VBA code?
Open the VBA Editor by pressing ALT + F11, click on the 'Debug' menu at the top, and select 'Compile VBAProject'. If there are errors, the editor will highlight the problematic lines of code so you can correct them before running the macro.
Can I edit and run VBA macros in WPS Office?
Yes, WPS Office supports VBA. You can open Microsoft Excel .xlsm files, access the Developer tab, edit standard modules in the Visual Basic Editor, and run macros with excellent cross-platform compatibility.




