ShortcutAdd Event

Microsoft Outlook Visual Basic

Show All

ShortcutAdd Event

       

Occurs when a new shortcut is added to a Outlook Bar group. This event is not available in VBScript.

Sub object_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 example changes the name of a Calendar shortcut when it is added to the first group in the Outlook Bar. 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 Schedule"
    End If
End Sub