VBA & Macro Problems

Fix an Excel Workbook That Becomes Zero Bytes After Saving

Emma BrownEmma Brown Nov 22, 2026 868 views

Question details

Identify why a macro-enabled Excel workbook becomes a zero-byte file during a save or close operation.

Fix an Excel Workbook That Becomes Zero Bytes After Saving
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.
Before you start

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.

Solution 1Recommended

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.

1
Inspect workbook events

Open the test workbook in Excel, press Alt+F11, and inspect ThisWorkbook for Workbook_BeforeClose, Workbook_BeforeSave, and any routines they call.

2
Find file operations

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.

3
Add diagnostic logging

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.

4
Check file size after operations

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.

5
Compare the results

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.

Trace VBA save, copy, and close operations
Interpret size checks carefully: A size observed while a save or copy is still in progress may be temporary. Check after the operation completes and record any errors rather than treating a single intermediate result as the cause.
Free Microsoft Office alternative

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.

Open and edit Excel-compatible XLSX spreadsheetsUse a familiar interface for everyday spreadsheet workMove existing Office documents into a lightweight, free suiteWork with spreadsheet data while investigating the Excel-specific save issue separately
microsoft office alternative - wps office

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.