Class OutlookBarShortcut (Outlook VBA)
The class OutlookBarShortcut represents a shortcut in a group in the Shortcuts pane. To use a OutlookBarShortcut class variable it first needs to be instantiated, for example
Dim obs as OutlookBarShortcut
Set obs = ActiveExplorer.Panes(1).Contents.Groups(1).Shortcuts(Index:=1)
For Each
Here is an example of processing the OutlookBarShortcut items in a collection.
Dim obsShortcut As OutlookBarShortcut
For Each obsShortcut In ActiveExplorer.Panes(1).Contents.Groups(1).Shortcuts
Next obsShortcut
Class
Returns an OlObjectClass constant indicating the object's class. Here you can find possible values for
Dim oocsClass As OlObjectClass
oocsClass = ActiveExplorer.Panes(1).Contents.Groups(1).Shortcuts(1).Class
Name
Returns or sets a String value that represents the display name for the object.
ActiveExplorer.Panes(1).Contents.Groups(1).Shortcuts(1).Name =
Session
Returns the NameSpace object for the current session.
The Session property and the GetNamespace method can be used interchangeably to obtain the NameSpace object for the current session. Both members serve the same purpose. For example, the following statements do the same function:
SetIcon
Sets the icon for the specified shortcut on the Shortcuts pane.
SetIcon (Icon)
Icon: The path of the icon.
Sub CreateMSNShortcutWithIcon()
Dim exp As Outlook.Explorer
Dim pans As Outlook.Panes
Dim bpan As Outlook.OutlookBarPane
Dim bgrps As Outlook.OutlookBarGroups
Dim bgrp As Outlook.OutlookBarGroup
Dim bscs As Outlook.OutlookBarShortcuts
Dim bsc As Outlook.OutlookBarShortcut
Dim bsc2 As Outlook.OutlookBarShortcut
Set exp = Application.ActiveExplorer
Set pans = exp.Panes
Set bpan = pans.Item("OutlookBar")
Set bgrps = bpan.Contents.Groups
Set bgrp = bgrps.Add("MicrosoftSites")
Set bscs = bgrp.Shortcuts
Set bsc = bscs.Add("https://www.msn.com", "MSN Home Page")
bsc.SetIcon "C:\MSN.ico"
End Sub
Target
Returns a Variant indicating the target of the specified shortcut in a Shortcuts pane group.
The return type depends on the shortcut type. If the shortcut represents an Outlook folder, the return type is Folder. If the shortcut represents a file-system folder, the return type is an Object. If the shortcut represents a file-system path or URL, the return type is a String.
Sub DeleteShortcuts()
Dim myOlBar As Outlook.OutlookBarPane
Dim myolGroup As Outlook.OutlookBarGroup
Dim myOlShortcuts As Outlook.OutlookBarShortcuts
Dim myOlShortcut As Outlook.OutlookBarShortcut
Dim myTop As Integer
Dim x As Integer
Dim count As Integer
Set myOlBar = Application.ActiveExplorer.Panes.Item("OutlookBar")
Set myolGroup = myOlBar.Contents.Groups.Item(1)
Set myOlShortcuts = myolGroup.Shortcuts
myTop = myOlShortcuts.Count
For x = myTop To 1 Step -1
Set myOlShortcut = myOlShortcuts.Item(x)
If TypeName(myOlShortcut.Target) = "Folder" Then
count = count + 1
End If
Next x
MsgBox ("Number of shortcuts that are Outlook folders:" & count)
End Sub