应用于 OutlookBarGroup 对象的 ViewType 属性。
返回或设置指定 Outlook 面板组所显示的图标视图。OlOutlookBarViewType 常量,可读写。
OlOutlookBarViewType 可为以下 OlOutlookBarViewType 常量之一。 |
olLargeIcon |
olSmallIcon |
expression.ViewType
expression 必选。该表达式返回 OutlookBarGroup 对象。
返回当前视图的类型。OlViewType 常量,只读。
OlViewType 可为以下 OlViewType 常量之一。 |
olCalendarView |
olCardView |
olIconView |
olTableView |
olTimelineView |
expression.ViewType
expression 必选。该表达式返回 View 对象。
以下 Microsoft Visual Basic/Visual Basic for Applications 示例将第一个 Outlook 面板组在大图标视图和小图标视图之间切换。
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
如果使用 VBScript,您不必创建 Application 对象,而且也不能使用命名常量。本示例说明如何使用 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
以下示例显示用户“收件箱”中所有视图的名称和类型。
Sub DisplayViewMode()
'Displays the names and view modes for all views
Dim olApp As Outlook.Application
Dim objName As NameSpace
Dim objViews As Views
Dim objView As View
Dim strTypes As String
Set olApp = Outlook.Application
Set objName = olApp.GetNamespace("MAPI")
Set objViews = objName.GetDefaultFolder(olFolderInbox).Views
'Collect names and view types for all views
For Each objView In objViews
strTypes = strTypes & objView.Name & vbTab & vbTab & objView.ViewType & vbCr
Next objView
'Display message box
MsgBox "Current Inbox Views and Viewtypes:" & vbCr & _
vbCr & strTypes
End Sub