SetIcon Method

Microsoft Outlook Visual Basic

SetIcon Method

       

Sets the icon for the specified Microsoft Outlook bar shortcut.

expression.SetIcon(Icon)

expression   Required. An expression that returns an OutlookBarShortcut object.

Icon  Required Variant. The path of the icon.

Example

The following example sets the icon of all shortcuts with the target MAPIFolder object to the icon image Mail.ico located on the user's computer. The example assumes that this icon exists in the specified location.

Sub SetFolderIcon()

    Dim OlApp As New Outlook.Application
    Dim objOlBar As Outlook.OutlookBarPane
    Dim objolGroup As Outlook.OutlookBarGroup
    Dim objOlShortcuts As Outlook.OutlookBarShortcuts
    Dim objOlShortcut As Outlook.OutlookBarShortcut
    Dim intTop As Integer
    Dim i As Integer

    Set objOlBar = OlApp.ActiveExplorer.Panes.Item("OutlookBar")
    Set objolGroup = objOlBar.Contents.Groups.Item(1)
    Set objOlShortcuts = objolGroup.Shortcuts
    intTop = objOlShortcuts.Count
    For i = intTop To 1 Step -1
        Set objOlShortcut = objOlShortcuts.Item(i)
        If TypeName(objOlShortcut.Target) = "MAPIFolder" Then
            objOlShortcut.SetIcon _
                ("C:\Program Files\Microsoft Office\Office\forms\1033\Mail.ico")
        End If
    Next i

End Sub