Folder.Views property (Outlook)

Returns the Views collection object of the Folder object. Read-only.

Syntax

expression. Views

expression A variable that represents a Folder object.

Example

The following Microsoft Visual Basic for Applications (VBA) example creates an instance of the Views collection and displays the XML definition of a view called "Table View". If the view does not exist, it creates one.

Sub DisplayViewDef() 
 
 'Displays the XML definition of a View object 
 
 Dim objName As Outlook.NameSpace 
 
 Dim objViews As Outlook.Views 
 
 Dim objView As Outlook.View 
 
 
 
 Set objName = Application.GetNamespace("MAPI") 
 
 Set objViews = objName.GetDefaultFolder(olFolderInbox).Views 
 
 'Return a view called Table View if it already exists, else create one 
 
 Set objView = objViews.Item("Table View") 
 
 If objView Is Nothing Then 
 
 Set objView = objViews.Add("Table View", olTableView, _ 
 
 olViewSaveOptionAllFoldersOfType) 
 
 End If 
 
 MsgBox objView.XML 
 
End Sub

See also

Folder Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.