ViewField Object (Outlook)
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

ViewField Object (Outlook)

Represents a view field, used to display information in a view.

Version Added: Outlook 2007

Use the Add method of the ViewFields collection to add an Outlook item property to the following objects derived from the View object:

Use the ColumnFormat property to access the ColumnFormat object representing the display properties associated with the view field. Use the ViewXMLSchemaName property to obtain the name of the view field as referenced in the XML definition of the view.

The following Visual Basic for Applications (VBA) example iterates through the ViewFields collection of the current TableView object, displaying the label and XML schema names of each ViewField object in the collection.

Private Sub DisplayTableViewFields() 
 Dim objTableView As TableView 
 Dim objViewField As ViewField 
 Dim strOutput As String 
 If Application.ActiveExplorer.CurrentView.ViewType = _ 
 olTableView Then 
 ' Obtain a TableView object reference for the 
 ' current table view. 
 Set objTableView = _ 
 ' Iterate through the ViewFields collection for 
 ' the table view, obtaining the label and the 
 ' XML schema name for each field included in 
 ' the view. 
 For Each objViewField In objTableView.ViewFields 
 With objViewField 
 strOutput = strOutput & .ColumnFormat.Label & _ 
 " (" & .ViewXMLSchemaName & ")" & vbCrLf 
 End With 
 ' Display a dialog box containing the concatenated 
 ' view field information. 
 MsgBox strOutput 
 End If 
End Sub 

© 2016 Microsoft