Partager via


ShortcutAdd Event

Occurs when a new shortcut is added to a Shortcuts pane group. This event is not available in Microsoft Visual Basic Scripting Edition (VBScript).

Subobject**_ShortcutAdd(ByVal NewShortcut As OutlookBarShortcut)**

*object   * An expression that evaluates to an OutlookBarShortcuts collection object.

NewShortcut Required **OutlookBarShortcut**object. The shortcut that is being added.

Example

This Microsoft Visual Basic/Visual Basic for Applications (VBA) example changes the name of a Calendar shortcut when it is added 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 myOlSCuts As Outlook.OutlookBarShortcuts
Dim myOlBar As Outlook.OutlookBarPane

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

Private Sub myOlSCuts_ShortcutAdd(ByVal NewShortcut As outlook.OutlookBarShortcut)
    Dim myNS As Outlook.NameSpace
    Set myNS = myOlApp.GetNamespace("MAPI")
    If NewShortcut.Target.Name = "Calendar" Then
        NewShortcut.Name = myNS.CurrentUser & "'s Schedules"
    End If
End Sub

Applies to | OutlookBarShortcuts Object

See Also | Add Method | BeforeShortcutAdd Event | OutlookBarShortcut Object | Using events with Automation