Excel VBA macro interruption causes application crash and closes all workbooks

Higgins Sylvia 50 Reputation points
2025-09-30T07:22:46.7033333+00:00

I am encountering a critical issue in Microsoft Excel (Microsoft 365 Apps for enterprise, Build 19127.20222 on Windows 11 Pro, Version 23H2) where interrupting a runaway VBA macro (e.g., an endless loop) using Ctrl+Break causes the entire Excel application to crash, closing all open workbooks without save prompts, leading to data loss across multiple .xlsm files in an enterprise environment.

This is reproducible with multiple workbooks open, logged in Event Viewer as EXCEL.EXE with exception code 0xc0000005 (faulting module VBA7.DLL), and persists despite troubleshooting like Safe Mode, disabling add-ins, and Office Repair.

Has anyone identified workarounds

Microsoft 365 and Office | Development | Other
{count} votes

Answer accepted by question author
  1. Steven-N 14,585 Reputation points Microsoft External Staff Moderator
    2025-09-30T08:26:38.07+00:00

    Hi Higgins Sylvia

    Thanks for reaching out to Microsoft Q&A forum support and apologize for the inconvenience. 

    Based on your description and from my own research, the root cause of this issue is a memory access violation in the VBA runtime environment when the interrupt command attempts to halt execution, leaving hidden breakpoints or corrupted memory states that Excel cannot recover from, especially under the Windows 11 23H2 environment. This is recognized as a critical VBA runtime instability issue affecting enterprise usage and there is currently no permanent fix, but you can follow the workaround methods below to mitigate this issue. 

    Option 1: Recompile VBA code 

    • Open Excel first with a blank workbook. 
    • Hold the Shift key while opening your .xlsm file(s) to prevent auto-run macros. 
    • Press Alt+F11 to open the VBA Editor. 
    • Go to Debug > Compile VBAProject (repeat if errors appear, fixing any highlighted issues). 
    • Save the file and close/reopen normally. 
    • Repeat for all affected workbooks. This clears corruption in the VBA binary and has resolved similar random crashes. If crashes persist, export all modules/forms, create a new workbook, and import them back. 

    Option 2: Disable macro interruptions temporarily 

    • In your macro code, add Application.EnableCancelKey = xlDisabled at the beginning. 
    • Add Application.EnableCancelKey = xlInterrupt at the end. 
    • This prevents Ctrl+Break from triggering the crash but still allows manual stops via the VBA Editor's Reset button if needed. Use this as a workaround for production macros, but test thoroughly, it's not ideal for debugging endless loops 

    In case after trying both of the above options but the problem is still not resolved, you can try to check if your software systems are fully updated by: 

    • Update Office to the latest build via File > Account > Update Options > Update Now
    • Test on a different machine or user profile to rule out profile-specific issues. 
    • Use Process Monitor (from Sysinternals) to log Excel.exe activity during a crash reproduction, filtering for VBE7.DLL accesses 

    If these don't resolve it, could you please provide more details like a code snippet from the problematic macro or full Event Viewer XML for deeper analysis. 

    I am looking forward to hearing update from you


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".     

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.  


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.