ViewType Property Example

The following Microsoft Visual Basic/Visual Basic for Applications example toggles the first Outlook Bar group between the large and small icon views.

Dim myOlApp As New Outlook.Application
Dim myOlBar As Outlook.OutlookBarPane
Dim myOlGroup As Outlook.OutlookBarGroup
Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
Set myOlGroup = myOlBar.Contents.Groups.Item(1)
If myOlGroup.ViewType = olLargeIcon Then
    myOlGroup.ViewType = olSmallIcon
Else
    myOlGroup.ViewType = olLargeIcon
End If

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myOlBar = Application.ActiveExplorer.Panes.Item("OutlookBar")
Set myOlGroup = myOlBar.Contents.Groups.Item(1)
If myOlGroup.ViewType = 0 Then
    myOlGroup.ViewType = 1
Else
    myOlGroup.ViewType = 0
End If