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