An implementation of Visual Basic that is built into Microsoft products.
Thank you for reaching out .
Understanding the Issue
You’re seeing Excel crash or close unexpectedly when calling:
wb.Close SaveChanges:=False
This behavior is known to occur intermittently, especially when Excel is launched through Task Scheduler or VBScript, rather than when you run the macro directly in the VBA editor.
Observations
- It does not happen in earlier builds, but appears in Microsoft 365 Version 2506 (Build 18925.20216).
- Common mitigations like
Application.DisplayAlerts = False,wb.Saved = True, and disabling add-ins often don’t resolve the issue in scheduled/automated contexts.
What You Can Check
- Updates
Make sure Excel is on the latest release:\ File > Account > Update Options > Update Now\ Newer builds sometimes contain stability fixes.
- Environment Differences
Confirm the scheduled task runs under the same user account and permissions as your interactive session. Excel behaves differently in a non-interactive environment (e.g., background service or SYSTEM account).
- Hidden or Minimized Windows
Crashes may occur if a workbook is hidden or minimized. If your automation opens Excel invisibly, try making the workbook visible before closing:
Application.Visible = True
Windows(wb.Name).Visible = True
- Event Viewer Logs
If Excel still shuts down, check Windows Event Viewer:
- Go to Event Viewer > Windows Logs > Application
- Look for crash entries related to Excel.exe This may help confirm the trigger or pinpoint the faulting module.
Workarounds You Can Try
- Let the External Script Close Excel (Recommended)
Instead of calling wb.Close in VBA, let the macro complete, and close Excel from your VBScript or Task Scheduler script:
objWorkbook.Saved = True
objWorkbook.Close
objExcel.Quit
This avoids the close operation in VBA, which is more reliable when Excel runs “headless.”
- Delay the Close Inside VBA
If you must close from VBA, schedule it slightly later so Excel finishes its background operations first:
Application.OnTime Now + TimeValue("00:00:02"), "CloseMe"
Sub CloseMe()
ThisWorkbook.Saved = True
ThisWorkbook.Close SaveChanges:=False
- Repair Office Installation
If issues persist even outside automation, try an Online Repair:
- Go to Settings > Apps > Installed Apps
- Find Microsoft Office
- Choose Modify > Online Repair
This has resolved similar workbook-related crashes for other users.
- Roll Back to an Earlier Build (If Critical)
If this is business-critical and unresolved, your IT team can roll back to a stable build using:
OfficeC2RClient.exe /update user updatetoversion=16.0.xxxxx.yyyyy
Or configure rollback via Group Policy.
- Monitor Updates
Keep an eye on:
for fixes related to workbook close or automation stability.
Summary
- The crash is most likely triggered by how Excel handles workbook closure in non-interactive sessions (VBS/Task Scheduler).
- Immediate workaround: Let your external script handle closing Excel instead of VBA.
- Secondary options: Defer closure with
Application.OnTime, ensure the workbook is visible, or perform an Online Repair. - Long-term: Stay updated or roll back to an earlier stable build if needed.
References
- https://learn.microsoft.com/en-us/office/troubleshoot/office-suite-issues/automate-office-applications
- https://support.microsoft.com/en-us/office/repair-an-office-application-7821d4b6-7c1d-4205-aa0e-a6b40c5bb88b
- https://learn.microsoft.com/en-us/deployoffice/updates/office-c2r-client-options
- Monthly Enterprise Channel Release Notes
- Microsoft Update Catalog
Let me know if you need any further help with this. We'll be happy to assist.
If you find this helpful, please mark this as answered.