Force Save As Before Saving or Printing an Excel Workbook with VBA
Question details
Require a Save As operation before saving or printing an Excel workbook, with a choice between a finished file and a work in progress.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- The user wants to preserve the original workbook, select a new file for each save or print action, and remove a temporary worksheet from finished copies.
- Observed behavior
- The desired workflow prompts for a file status and destination before saving or printing, then removes the temporary worksheet when the finished option is selected.
Use a desktop version of Excel that supports VBA, enable macros for the test workbook, and test the event code on a copy. Identify the temporary worksheet name and any workbook structure password before editing the code.
Use workbook events to require Save As before saving or printing
Use this VBA approach to prompt for a finished or work-in-progress copy before Excel saves or prints the workbook.
The BeforeSave event cancels the original save, while BeforePrint cancels printing if the save routine does not complete. The routine disables events during SaveAs to prevent recursive prompts and restores the previous event and alert settings afterward.
This example creates macro-enabled .xlsm files and refuses to save over the workbook's current path. After a successful Save As, the new file becomes the current workbook, so this check alone does not permanently protect the original file.
Open the workbook in desktop Excel, press Alt+F11, and double-click ThisWorkbook in the Project pane. If the workbook already has BeforeSave or BeforePrint handlers, integrate the calls into those handlers instead of adding duplicates.
Paste the following code into ThisWorkbook. Replace TempSheet with the temporary worksheet's exact name and replace the password placeholder if workbook structure protection is used: Option Explicit Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Cancel = True SaveNewCopy End Sub Private Sub Workbook_BeforePrint(Cancel As Boolean) Cancel = Not SaveNewCopy() End Sub Private Function SaveNewCopy() As Boolean Dim choice As VbMsgBoxResult Dim destination As Variant Dim temp As Worksheet Dim oldEvents As Boolean Dim oldAlerts As Boolean oldEvents = Application.EnableEvents oldAlerts = Application.DisplayAlerts On Error GoTo Failed choice = MsgBox("Is this file finished?" & vbCrLf & _ "Yes = Finished; No = Work in Progress; Cancel = stop.", _ vbYesNoCancel + vbQuestion, "File status") If choice = vbCancel Then GoTo CleanUp destination = Application.GetSaveAsFilename( _ InitialFileName:="Workbook copy.xlsm", _ FileFilter:="Excel Macro-Enabled Workbook (*.xlsm), *.xlsm") If VarType(destination) = vbBoolean Then GoTo CleanUp If LCase$(Right$(CStr(destination), 5)) <> ".xlsm" Then MsgBox "Choose a file name ending in .xlsm." GoTo CleanUp End If If StrComp(CStr(destination), ThisWorkbook.FullName, vbTextCompare) = 0 Then MsgBox "Choose a different file from the current workbook." GoTo CleanUp End If If choice = vbYes Then On Error Resume Next Set temp = ThisWorkbook.Worksheets("TempSheet") On Error GoTo Failed If Not temp Is Nothing Then If ThisWorkbook.ProtectStructure Then ThisWorkbook.Unprotect Password:="YOUR_PASSWORD" End If If ThisWorkbook.ProtectStructure Then Err.Raise vbObjectError + 1, , "Workbook structure is still protected." End If Application.DisplayAlerts = False temp.Delete Application.DisplayAlerts = oldAlerts End If End If Application.EnableEvents = False ThisWorkbook.SaveAs Filename:=CStr(destination), _ FileFormat:=xlOpenXMLWorkbookMacroEnabled SaveNewCopy = True GoTo CleanUp Failed: MsgBox "The new copy was not saved: " & Err.Description, vbExclamation CleanUp: Application.EnableEvents = oldEvents Application.DisplayAlerts = oldAlerts End Function
Save the test workbook as an Excel Macro-Enabled Workbook (.xlsm), reopen it with macros enabled, and use File > Save and File > Print. Test Yes, No, and Cancel, and verify the destination file and temporary worksheet.

Work with Excel workbooks in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface. Open compatible Excel files and move everyday spreadsheet work to WPS, while keeping Excel for workflows that depend on its VBA events.

Frequently Asked Questions
Why does SaveAs trigger the save prompt again?
SaveAs can trigger Workbook_BeforeSave. Set Application.EnableEvents to False around the SaveAs call, then restore its previous value in a cleanup path, including after errors.
Will canceling Save As also stop printing?
In the example, yes. Workbook_BeforePrint sets Cancel to True when the shared save routine returns False, including when the user cancels the file dialog or a save error occurs.
Why is the temporary worksheet still in my finished file?
Check that TempSheet in the ThisWorkbook code exactly matches the worksheet name and that you selected Yes for Finished. If workbook structure is protected, supply the correct password so the sheet can be deleted.
Can this code guarantee that the original workbook is never overwritten?
No. It prevents saving to the current workbook path, but that path changes after SaveAs. Macros can also be disabled, so protect the original separately, for example by keeping a read-only master in a restricted location.




