Fix Excel Closing or Restarting When a VBA UserForm Closes
Question details
The user needs to identify why Excel closes or restarts when a VBA UserForm is unloaded.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A workbook uses a VBA UserForm that may interact with Excel objects or external CAD software.
- Observed behavior
- Excel closes or restarts when the UserForm is unloaded.
Note whether the issue occurs when closing a particular UserForm, and whether the workbook is stored in OneDrive or uses CAD automation. Make a local test copy so you can compare its behavior without cloud synchronization.
Isolate the workbook, add-ins, and UserForm code
Use a local test copy and a blank workbook to narrow down whether the crash comes from the workbook, add-ins, or VBA automation.
Open the workbook in Excel and use File > Save As to create a copy in a local folder outside OneDrive. Open that copy and test closing the UserForm.
In Excel, open File > Options > Add-ins. Select Excel Add-ins or COM Add-ins in the Manage box, click Go, and clear the enabled add-ins for testing. Re-enable them one at a time after the test.
Create a blank workbook with File > New, then use Developer > Visual Basic to add a simple UserForm. Show and close it to see whether the problem also occurs without the original workbook's code.
In Developer > Visual Basic, open the UserForm's code and inspect its QueryClose and Terminate event procedures. Add error handling and log error details; avoid using End or code that forcibly terminates Excel.
In the VBA editor, review code that runs when the form closes. Release unused CAD and Excel object references with Set objectVariable = Nothing, and check that cleanup or save operations are not interrupting shutdown.

Check Excel crash details and repair Office
Use this approach if Excel still crashes after the local workbook and code tests, or if the issue started after an Office update.
Work with Excel spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Microsoft Office format compatibility, making it easier to move everyday workbook work between applications. It does not repair Microsoft Excel or guarantee compatibility with VBA UserForms and CAD automation.

Frequently Asked Questions
Can OneDrive cause Excel to crash when a UserForm closes?
Synchronization or a save during shutdown can complicate troubleshooting. Use File > Save As to make a local copy outside OneDrive, then test whether closing the form still causes the crash.
Which UserForm events should I check?
In Developer > Visual Basic, open the UserForm's code and inspect QueryClose and Terminate. Look for unhandled errors, save operations, automation cleanup, and statements such as End.
How do I check whether an add-in is involved?
Go to File > Options > Add-ins, choose Excel Add-ins or COM Add-ins under Manage, and click Go. Disable the add-ins temporarily, test the form, and then re-enable them one at a time.
Where can I find information about an Excel crash on Windows?
Open Event Viewer and go to Windows Logs > Application. Look for an error recorded at the time of the crash and note the faulting application and module.
Will WPS Office fix my Excel UserForm crash?
No. WPS Office is an alternative for everyday spreadsheet work, not a repair for Microsoft Excel. Test any workbook that depends on VBA UserForms or CAD automation for compatibility before relying on it in another application.




