How to Fix Excel Crashes When Enabling Macros in VBA Workbooks
Question details
The user experiences unexpected application crashes when opening macro-enabled workbooks and enabling macros.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Opening a macro-enabled workbook where VBA startup code executes immediately via the Auto_Open procedure.
- Observed behavior
- Excel crashes upon initializing the VBA macros, a problem often noticed after installing newer Microsoft 365 update builds.
Ensure you have the VBA project password if the workbook is protected, as you may need to access the code editor to implement delays or compile the project.
Delay Startup Code Execution in Auto_Open
Prevent initialization crashes by using Application.OnTime to delay the execution of your VBA startup code.
When Excel opens a workbook, running heavy macro operations immediately can cause the application to crash before its internal components fully load. Shifting the main logic to a separate procedure and introducing a slight delay allows Excel to stabilize.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor in Excel.
Move your existing startup code from the Auto_Open function into a new, separate public subroutine (for example, name it Sub my_Procedure()).
Inside your Auto_Open procedure, type the following code: Application.OnTime Now + TimeValue("00:00:01"), "my_Procedure".
Save the workbook and test it. If Excel continues to crash, increase the TimeValue delay to two or three seconds (e.g., "00:00:03").

Compile the VBA Project
Compiling the code can resolve underlying syntax or reference errors that might cause Excel to crash upon macro activation.
Disable COM Add-ins
Identify potential initialization conflicts by temporarily disabling third-party add-ins.
Experience Stable Macro Execution with WPS Office
If Microsoft Excel continues to crash due to software updates or complex initialization sequences, consider switching to WPS Office. It provides a lightweight, highly compatible alternative that natively supports VBA macros and .xlsm formats without the heavy system footprint.
- 1. Download and Install: Visit the official WPS Office website to download the free installation package for your operating system.
- 2. Open Your Workbook: Launch WPS Spreadsheet and simply open your existing macro-enabled (.xlsm) file.
- 3. Enable Macros: Click 'Enable Macros' when prompted by the security warning to safely run your VBA code.

Frequently Asked Questions
Why does Excel crash immediately when I enable macros?
This frequently occurs when an automated macro (like Auto_Open or Workbook_Open) executes before Excel has fully loaded its internal components and user interface, causing an initialization conflict.
How do I run a macro with a delay in Excel VBA?
You can delay a macro by using the Application.OnTime method. For example, Application.OnTime Now + TimeValue("00:00:03"), "MacroName" schedules 'MacroName' to run 3 seconds after the command is executed.
Can compiling the VBA project fix Excel crashes?
Yes. Going to Debug > Compile VBAProject forces the editor to check for syntax errors and broken references, resolving backend issues that might otherwise cause newer builds of Excel to crash.
Will macros created in Microsoft Excel work in WPS Office?
Yes, WPS Office supports VBA macros. You can open your existing .xlsm files in WPS Spreadsheet and run your automated workflows smoothly, often bypassing bugs specific to recent Microsoft Office updates.




