Skip to content

Latest commit

 

History

History
50 lines (30 loc) · 1.09 KB

Excel.Workbook.BeforeClose.md

File metadata and controls

50 lines (30 loc) · 1.09 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Workbook.BeforeClose event (Excel)
vbaxl10.chm503076
vbaxl10.chm503076
Excel.Workbook.BeforeClose
1c440637-8289-c6dd-24e0-1b2764fd1694
05/29/2019
medium

Workbook.BeforeClose event (Excel)

Occurs before the workbook closes. If the workbook has been changed, this event occurs before the user is asked to save changes.

Syntax

expression.BeforeClose (Cancel)

expression A variable that represents a Workbook object.

Parameters

Name Required/Optional Data type Description
Cancel Required Boolean False when the event occurs. If the event procedure sets this argument to True, the close operation stops and the workbook is left open.

Return value

Nothing

Example

This example always saves the workbook if it has been changed.

Private Sub Workbook_BeforeClose(Cancel as Boolean) 
 If Me.Saved = False Then Me.Save 
End Sub

[!includeSupport and feedback]