【发布时间】:2012-08-15 23:13:11
【问题描述】:
我真的不知道 DocumentBeforeClose 事件的语法。在this 页面之后,我应该创建一个名为“EventClassModule”的类模块(另见this 文章)。所以我做了。然后我将这段代码(来自第一个链接的示例)复制到那个(类)模块中:
Public WithEvents appWord as Word.Application
Private Sub appWord_DocumentBeforeClose _
(ByVal Doc As Document, _
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
最后我把它放在一个普通的模块中,并执行它:
Dim X As New EventClassModule
Sub Register_Event_Handler()
Set X.App = Word.Application
End Sub
在这种情况下,“X”是什么意思,我做错了什么?我现在关闭文档时没有执行任何事件。
【问题讨论】: