logo
search
VBA & Macro Problems

How to Fix Excel Crashes When Enabling Macros in VBA Workbooks

Rana GarciaRana Garcia Oct 19, 2026 868 views

Question details

The user experiences unexpected application crashes when opening macro-enabled workbooks and enabling macros.

How to Fix Excel Crashes When Enabling Macros in VBA Workbooks
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor in Excel.

2
Create a New Procedure

Move your existing startup code from the Auto_Open function into a new, separate public subroutine (for example, name it Sub my_Procedure()).

3
Implement the Delay

Inside your Auto_Open procedure, type the following code: Application.OnTime Now + TimeValue("00:00:01"), "my_Procedure".

4
Increase the Delay if Necessary

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").

Delay Startup Code Execution in Auto_Open
Tip: A one- to three-second delay is typically long enough to let Excel finish loading its add-ins and UI elements without severely impacting the user experience.
Free Microsoft Office alternative

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. 1. Download and Install: Visit the official WPS Office website to download the free installation package for your operating system.
  2. 2. Open Your Workbook: Launch WPS Spreadsheet and simply open your existing macro-enabled (.xlsm) file.
  3. 3. Enable Macros: Click 'Enable Macros' when prompted by the security warning to safely run your VBA code.
Fully compatible with Microsoft Excel file formats, including .xlsx and .xlsm.Includes robust native support for VBA macros, allowing seamless workflow migration.Lightweight architecture ensures faster startup times and minimal application crashes.Familiar tabbed user interface that requires no additional learning curve.
microsoft office alternative - wps office

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.