共用方式為


OutlookBarShortcuts.BeforeShortcutAdd 事件 (Outlook)

會在快 方式窗格中將新的快捷方式新增至群組之前發生,可能是因為使用者動作或程式碼所造成。

語法

expressionBeforeShortcutAdd( _Cancel_ )

表達 代表 OutlookBarShortcuts 物件的 變數。

參數

名稱 必要/選用 資料類型 描述
Cancel 必要 布林值 False 事件發生時。 如果事件程序將此引數設定為 True,則不會將捷徑新增到群組。

註解

Microsoft Visual Basic Scripting Edition (VBScript) 中沒有這個事件。

範例

下列 Microsoft Visual Basic for Applications (VBA) 範例會防止使用者將快捷方式新增至 [快捷方式 ] 窗格中的第一個群組。 範例程式碼必須放在類別模組中,而且 Initialize_handler 必須先呼叫常式,Microsoft Outlook 才能呼叫事件程序。

Dim WithEvents myOlShortcuts As Outlook.OutlookBarShortcuts 
Dim myOlBar As Outlook.OutlookBarPane 
 
Sub Initialize_handler() 
 Set myOlBar = Application.ActiveExplorer.Panes.Item("OutlookBar") 
 Set myOlShortcuts = myOlBar.Contents.Groups.Item(1).Shortcuts 
End Sub 
 
Private Sub myOlShortcuts_BeforeShortcutAdd(Cancel As Boolean) 
 MsgBox "You are not allowed to add a shortcut to this group." 
 Cancel = True 
End Sub

另請參閱

OutlookBarShortcuts 物件

支援和意見反應

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