Skip to content

Latest commit

 

History

History
57 lines (36 loc) · 1.81 KB

Excel.Application.WorkbookBeforeSave.md

File metadata and controls

57 lines (36 loc) · 1.81 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Application.WorkbookBeforeSave event (Excel)
vbaxl10.chm504085
vbaxl10.chm504085
Excel.Application.WorkbookBeforeSave
e93a7cef-b018-ddab-c96f-b3215143f31f
04/05/2019
medium

Application.WorkbookBeforeSave event (Excel)

Occurs before any open workbook is saved.

Note

In Office 365, Excel supports AutoSave, which enables the user's edits to be saved automatically and continuously. For more information, see How AutoSave impacts add-ins and macros to ensure that running code in response to the WorkbookBeforeSave event functions as intended when AutoSave is enabled.

Syntax

expression.WorkbookBeforeSave (Wb, SaveAsUI, Cancel)

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
Wb Required Workbook The workbook.
SaveAsUI Required Boolean True if the Save As dialog box will be displayed due to changes made that need to be saved in the workbook.
Cancel Required Boolean False when the event occurs. If the event procedure sets this argument to True, the workbook isn't saved when the procedure is finished.

Return value

Nothing

Example

This example prompts the user for a yes or no response before saving any workbook.

Private Sub App_WorkbookBeforeSave(ByVal Wb As Workbook, _ 
 ByVal SaveAsUI As Boolean, Cancel as Boolean) 
 a = MsgBox("Do you really want to save the workbook?", vbYesNo) 
 If a = vbNo Then Cancel = True 
End Sub

[!includeSupport and feedback]