logo
search
VBA & Macro Problems

How to Fix Excel VBA Workbook.SaveAs Not Working for New Workbooks

Adam DavisAdam Davis Sep 25, 2026 869 views

Question details

The user needs to resolve an issue where the VBA Workbook.SaveAs method fails or is skipped when attempting to save a newly created workbook, specifically as an XLSB file.

Fix Excel VBA Workbook.SaveAs Not Working for a New Workbook
Product
Microsoft Excel
Device & OS
not provided
Scenario
Creating a new workbook via VBA and saving it programmatically as an XLSB (Excel Binary Workbook) file.
Observed behavior
The Workbook.SaveAs command appears to be completely skipped, and the new workbook is not saved to the destination folder.
Before you start

Ensure that the destination folder path specified in your VBA code actually exists and that you have the necessary write permissions. Also, verify that no other program is currently locking the file you are trying to overwrite.

Solution 1Recommended

Use DoEvents and Application.Ready Before Saving

This method ensures Excel has completely finished generating the new workbook in the background before attempting to execute the SaveAs command.

When VBA creates a new workbook, the process may run asynchronously in the background. If the code reaches the SaveAs command before Excel has fully built the workbook object, the save operation can be silently skipped or cause an error. Forcing the application to wait resolves this sync issue.

1
Locate the macro

Open your VBA Editor (ALT + F11) and find the macro where the new workbook is being created.

2
Insert a waiting loop

Right after the line of code that creates the workbook, insert a waiting loop by typing: Do While Not Application.Ready: DoEvents: Loop

3
Add the SaveAs command

Immediately after the loop, add your SaveAs command ensuring the correct file format for XLSB is specified: wbNewWorkbook.SaveAs Filename:=strFullName, FileFormat:=xlExcel12

4
Run and verify

Execute the macro again to confirm that the new workbook is successfully processed and saved in the destination folder.

Use DoEvents and Application.Ready Before Saving
Check FileFormat Enumeration: Always ensure you are using the correct FileFormat value. For an .xlsb file, xlExcel12 (or the numeric value 50) is strictly required.
WPS Spreadsheet Automation

Create and Save Macro Workbooks Easily in WPS Office

WPS Spreadsheet provides a built-in, highly compatible VBA editor. You can easily automate creating and saving workbooks as XLSB without experiencing the background lagging or skipped tasks often found elsewhere.

  1. 1. Download and Install WPS: Download WPS Office Free from the official website and install it on your device.
  2. 2. Open WPS Spreadsheet: Launch WPS Spreadsheet and navigate to the 'Developer' tab on the top ribbon.
  3. 3. Access the VBA Editor: Click on 'Visual Basic' to open the code editor. You can paste your existing macro code directly into a new module.
  4. 4. Run Your Macro: Execute your script to create and save the new workbook. WPS seamlessly handles background creation and xlExcel12 format saving.
Fully compatible with Microsoft Excel macro formats, including .xlsm and .xlsb.Stable macro execution environment that prevents SaveAs skipping issues.Lightweight software that processes automation scripts quickly and efficiently.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Excel skip the VBA Workbook.SaveAs command without throwing an error?

This typically happens because the VBA code executes faster than Excel can complete background tasks, such as generating a new workbook object. If the object isn't fully ready, VBA may skip the line. Using Application.Ready forces the code to wait until the application is free.

What FileFormat value should I use for an XLSB file in VBA?

To save a file as an Excel Binary Workbook (.xlsb), you must use the FileFormat property set to xlExcel12 (or the numeric value 50) in your SaveAs command.

Can a locked file cause the SaveAs method to fail?

Yes, if a file with the same name already exists in the destination folder and is currently open or locked by another application, the SaveAs command will fail to overwrite it. Always ensure the file is closed or use error handling to catch the issue.

What does DoEvents do in Excel VBA?

DoEvents pauses macro execution momentarily to yield execution to the operating system. This allows Excel to process other pending background events, like finishing the creation of a new workbook, before moving to the next line of code.