Share via

Workbook.Close method causes error/crash in Excel Version 2506 (Build 18925.20216)

石井 亮介 105 Reputation points
2025-09-03T01:30:20.28+00:00

Hello,

I’m encountering errors when using the VBA method Workbook.Close in Excel.

  • Environment:
    • Microsoft Excel for Microsoft 365
    • Version: 2506
    • Build: 18925.20216 (Monthly Enterprise Channel)
  • Issue: When I run VBA code to close a workbook (e.g., wb.Close SaveChanges:=False), Excel sometimes crashes, closes all workbooks, or throws errors unexpectedly. Previously the same code worked fine.
  • Steps already tried:
    • Used Application.DisplayAlerts = False
    • Set wb.Saved = True before closing
    • Ensured explicit workbook referencing (not ActiveWorkbook)
    • Disabled add-ins, ran in Safe Mode
    • Issue still reproduces
  • Additional context: I’ve seen similar issues reported earlier this year (around Jan and June–July 2025 updates). Could this be a regression in build 18925.20216? Are there any known fixes or recommended workarounds?
Developer technologies | Visual Basic for Applications

Answer accepted by question author

Varsha Dundigalla(INFOSYS LIMITED) 5,025 Reputation points Microsoft External Staff
2025-09-03T08:13:14.4366667+00:00

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

  1. Updates

Make sure Excel is on the latest release:\ File > Account > Update Options > Update Now\ Newer builds sometimes contain stability fixes.

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

  1. 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

  1. 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

  1. 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.”

  1. 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
  1. 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.

  1. 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.

  1. 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

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.

Was this answer helpful?

1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. 石井 亮介 105 Reputation points
    2025-09-04T04:46:36.0233333+00:00

    Mr. Viorel, Mr. Dundigalla, thank you very much for your prompt responses!

    Mr. Viorel, I understand that using VBA with Task Scheduler is not recommended, so I will consider switching to another approach to work toward a more fundamental solution.

    Mr. Dundigalla, thank you for suggesting countermeasures! Since it seems difficult to externalize Workbooks.Close in VBS and also difficult to upgrade the version, I plan to handle it using OnTime or Wait.

    Thank you very much!

    Was this answer helpful?

    0 comments No comments

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.