Skip to content

Latest commit

 

History

History
58 lines (36 loc) · 2.02 KB

Excel.Application.ProtectedViewWindowBeforeClose.md

File metadata and controls

58 lines (36 loc) · 2.02 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Application.ProtectedViewWindowBeforeClose event (Excel)
vbaxl10.chm504110
vbaxl10.chm504110
Excel.Application.ProtectedViewWindowBeforeClose
5fa37062-61c7-3002-1ea0-c5bd396b6a9b
04/05/2019
medium

Application.ProtectedViewWindowBeforeClose event (Excel)

Occurs immediately before a Protected View window or a workbook in a Protected View window closes.

Syntax

expression.ProtectedViewWindowBeforeClose (Pvw, Reason, Cancel)

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
Pvw Required ProtectedViewWindow An object that represents the Protected View window that is closed.
Reason Required XlProtectedViewCloseReason A constant that specifies the reason the Protected View window is closed.
Cancel Required Boolean False when the event occurs. If the event procedure sets this argument to True, the window does not close when the procedure is finished.

Return value

Nothing

Example

The following code example prompts the user for a yes or no response before closing the Protected View window. This code must be placed in a class module, and an instance of that class must be correctly initialized.

For more information about how to use event procedures with the Application object, see Using events with the Application object.

Private Sub App_ProtectedViewWindowBeforeClose(ByVal Pvw as ProtectedViewWindow, _ 
 Reason as XlProtectedViewCloseReason, Cancel as Boolean) 
 a = MsgBox("Do you really want to close the Protected View window?", _ 
 vbYesNo) 
 If a = vbNo Then Cancel = True 
End Sub

[!includeSupport and feedback]