Shortcuts Property

Microsoft Outlook Visual Basic

Returns an OutlookBarShortcuts collection of shortcuts contained within the Shortcuts pane.

expression.Shortcuts

expression    Required. An expression that returns an OutlookBarGroup object.

Example

This Microsoft Visual Basic/Visual Basic for Applications (VBA) example deletes all empty groups in the Shortcuts pane.

Sub DeleteEmptyGroups()
 Dim myOlApp As New Outlook.Application
 Dim myOlBar As Outlook.OutlookBarPane
 Dim myOlGroup As Outlook.OutlookBarGroup
 Dim x As Integer
 Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
 For x = myOlBar.Contents.Groups.Count To 1 Step -1
    Set myOlGroup = myOlBar.Contents.Groups.Item(x)
    If myOlGroup.Shortcuts.Count = 0 Then
        myOlBar.Contents.Groups.Remove x
    End If
 Next x
End Sub
		

If you use Microsoft Visual Basic Scripting Edition (VBScript) in a Microsoft Outlook form, you do not create the Application object. This example shows how to perform the same task using VBScript code.

Sub CommandButton1_Click()
 Set myOlBar = Application.ActiveExplorer.Panes.Item("OutlookBar")
 For x = myOlBar.Contents.Groups.Count To 1 Step -1
     Set myOlGroup = myOlBar.Contents.Groups.Item(x)
     If myOlGroup.Shortcuts.Count = 0 Then
         myOlBar.Contents.Groups.Remove x
     End If
 Next 
End Sub