Word) (Application.WindowBeforeRightClick 事件

會在預設的按滑鼠右鍵動作之前,以滑鼠右鍵按一下文件視窗的編輯區域時發生。

語法

Private Sub expression._'WindowBeforeRightClick** (Sel As Selection**, Cancel As Boolean)

表達 變數,表示已使用類別模組中的事件宣告的 'Application' 物件。

參數

名稱 必要/選用 資料類型 描述
Sel 必要 Selection 目前的選取範圍。
Cancel 必要 布林值 False 在事件發生時。 如果事件程序會將此引數為 True ,完成程序,並不會發生預設以滑鼠右鍵按一下動作。

註解

如需搭配 Application 物件使用 事件的詳細資訊,請參閱 搭配 Application 物件使用事件

範例

此範例會提示使用者的 [是] 或 [否] 回應之前執行預設以滑鼠右鍵按一下動作。 此程式碼必須放在類別模組中,而且必須正確初始化 類別的實例,才能讓此範例正常運作;如需如何完成此作業的指示,請參閱 搭配 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

另請參閱

Application 物件

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應