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's been changed.

Visual Basic for Applications
Private Sub Workbook_BeforeClose(Cancel as Boolean) If Me.Saved = False Then Me.Save End Sub
before before close Before Close Event Before workbook closes? beforeclose beforeclose event

See also: