全部显示

BeforeShortcutRemove 事件

       

在将新快捷方式Outlook 面板中的组删除前发生,可以是用户操作或程序代码的结果。该事件在 VBScript 中不可用。

Sub object_BeforeShortcutRemove(ByVal Shortcut As OutlookBarShortcut, Cancel As Boolean)

object  该表达式的值为 OutlookBarShortcuts 集合对象。

Shortcut  必选。要删除的 OutlookBarShortcut

Cancel  可选。当事件发生时为 False。如果事件过程将该参数设置为 True,将不从组中删除该快捷方式。

示例

以下示例防止用户从“Outlook 面板”上的第一个组中删除快捷方式。示例代码必须放在类模块中,并且在 Microsoft Outlook 调用该事件过程前必须调用 Initialize_handler 例程。

Dim myOlApp As New Outlook.Application
Dim WithEvents myOlShortcuts As Outlook.OutlookBarShortcuts
Dim myOlBar As Outlook.OutlookBarPane

Sub Initialize_handler()
    Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
    Set myOlShortcuts = myOlBar.Contents.Groups.Item(1).Shortcuts
End Sub

Private Sub myOlShortcuts_BeforeShortcutRemove(Cancel As Boolean)
    MsgBox "You are not allowed to remove a shortcut from this group."
    Cancel = True
End Sub