Document.BeforeClose 事件 (Publisher)

在打开的文档即将关闭之前发生。

语法

表达式BeforeClose (Cancel)

表达 一个代表 Document 对象的变量。

参数

名称 必需/可选 数据类型 说明
Cancel 必需 Boolean 的事件发生时。 如果该事件过程将此参数设置为 True ,则完成此过程后不关闭文档。

备注

有关对 Document 对象使用事件的详细信息,请参阅 对 Document 对象使用事件

示例

本示例在关闭文档之前,提示用户答复"是"或"否"。 为了使本示例生效,必须将此代码置于 ThisDocument 模块中。

Private Sub Document_BeforeClose(Cancel As Boolean) 
 Dim intResponse As Integer 
 
 intResponse = MsgBox("Do you really want to close " _ 
 & "the document?", vbYesNo) 
 
 If intResponse = vbNo Then Cancel = True 
End Sub

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。