BeforeShortcutAdd Event
Occurs before a new shortcut is added to a group in the Shortcuts pane, either as a result of user action or through program code. This event is not available in Microsoft Visual Basic Scripting Edition (VBScript).
Subobject**_BeforeShortcutAdd(Cancel As Boolean)**
*object * An expression that evaluates to an OutlookBarShortcuts collection object.
*Cancel * Optional. False when the event occurs. If the event procedure sets this argument to True, the shortcut is not added to the group.
Example
The following Microsoft Visual Basic/Visual Basic for Applications (VBA) example prevents a user from adding a shortcut to the first group in the Shortcuts pane. The sample code must be placed in a class module, and the Initialize_handler
routine must be called before the event procedure can be called by Microsoft Outlook.
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_BeforeShortcutAdd(Cancel As Boolean)
MsgBox "You are not allowed to add a shortcut to this group."
Cancel = True
End Sub
Applies to | OutlookBarShortcuts Object
See Also | Add Method | OutlookBarShortcut Object | ShortcutAdd Event | Using events with Automation