Fix an Excel Workbook That Becomes Zero Bytes After Saving
Question details
Identify why a macro-enabled Excel workbook becomes a zero-byte file during a save or close operation.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A workbook with VBA macros is saved or closed, potentially while file-copy routines or other users are accessing it.
- Observed behavior
- The workbook file sometimes becomes empty after a save or close operation.
Identify the affected workbook's full path and whether it is stored locally, on a network share, or in a synced folder. Use a noncritical test copy to reproduce the issue and avoid running macros from untrusted workbooks.
Trace VBA save, copy, and close operations
Use file-size checks and a separate log to identify the operation immediately preceding the zero-byte file.
Open the test workbook in Excel, press Alt+F11, and inspect ThisWorkbook for Workbook_BeforeClose, Workbook_BeforeSave, and any routines they call.
In the VBA editor, use Edit > Find to locate Save, SaveAs, Close, FileCopy, and other file-handling calls. Record their source and destination paths, and check whether they refer to ThisWorkbook or another workbook.
Add logging before and after each relevant operation to a separate log file. Include the timestamp, user, operation, workbook path, destination path when applicable, and any error number and description.
After each completed save or copy, use VBA's FileLen with the relevant full path and write the result to the log. Handle missing files and access errors separately. For a check after Close, run the logging code from another workbook or add-in, because code in the closed workbook will no longer run.
Run the test workflow and open the log to find the first completed operation followed by a zero-byte result. Investigate that routine for overwriting the same path, repeated close or save calls, and unhandled errors.

Isolate storage conflicts and recover an earlier workbook
Test whether the issue depends on shared storage or concurrent access, and look for a usable earlier version.
Work with spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for Microsoft Office formats, making it easy to move everyday spreadsheet work. It does not diagnose or repair Excel's VBA save behavior; check macro compatibility before migrating a VBA-dependent workbook.

Frequently Asked Questions
Can Excel repair a zero-byte workbook?
A zero-byte file has no workbook data for Excel to repair. Check Version History in OneDrive or SharePoint, or look under File > Info > Manage Workbook > Recover Unsaved Workbooks for a usable copy.
Where do I find the VBA code that runs when a workbook closes?
Press Alt+F11 in Excel, open ThisWorkbook in the VBA project, and look for Workbook_BeforeClose. Also inspect any procedures that event calls.
How can I check the workbook's file size in VBA?
Use FileLen with the workbook's full path after a save or copy completes, and log the result. Handle errors separately if the path is missing or inaccessible.
Could a network share or synced folder cause the problem?
Concurrent access, sync, or file-copy activity may contribute, but they are not confirmed causes. Use File > Save As to test a local copy and compare the results with the shared or synced location.




