WindowBeforeRightClick 事件

       

该事件在默认的右键单击操作发生之前,右键单击文档窗口的编辑区时发生。

Private Sub object_WindowBeforeRightClick(ByVal Sel As Selection, ByVal Cancel As Boolean)

object   在类模块的事件中声明的 Application 类型对象。有关使用 Application 对象的详细内容,请参阅使用 Application 对象事件

Sel   当前所选内容。

Cancel   如果为 False,则事件发生。如果事件过程将该参数设为 True,则过程完成时默认右键单击操作不会发生。

示例

本示例实现的功能是:执行默认右键单击操作前提示用户用“是”或“否”进行响应。本示例代码必须置于类模块中,并且类中的实例必须进行正确的初始化才能看到该示例的效果。有关如何完成本执行的指导,请参阅使用 Application 对象事件

Public WithEvents appWord as Word.Application

Private Sub appWord_WindowBeforeRightClick _
        (ByVal Sel As Selection, _
        Cancel As Boolean)
    Dim intResponse As Integer

    intResponse = MsgBox("Selection = " & Sel & vbLf & vbLf _
        & "Continue with operation on this selection?", _
        vbYesNo)
    If intResponse = vbNo Then Cancel = True
End Sub