当将新快捷方式添加到 Outlook 面板组中时发生。该事件在 VBScript 中不可用。
Sub object_ShortcutAdd(ByVal NewShortcut As OutlookBarShortcut)
object 该表达式的值为 OutlookBarShortcuts 集合对象。
NewShortcut 必选的 OutlookBarShortcut 对象。要添加的快捷方式。
本示例在将“日历”快捷方式添加到 Outlook 面板的第一个组中时,更改快捷方式的名称。示例代码必须放在类模块中,并且在 Microsoft Outlook 调用该事件过程前必须调用 Initialize_handler
例程。
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