Compartir a través de


ViewFields Object (Outlook)

Represents the collection of ViewField objects in a view.

Version Information

Version Added: Outlook 2007

Remarks

The ViewFields collection represents the Outlook item properties available for display in the view. Use the Add method of the ViewFields collection to add a view field for the following objects derived from the View object:

In a table view, the order of ViewField objects in the ViewFields collection is not the same as the order that field columns are displayed in the table view. A workaround to obtain the column order is to parse the string returned by the View.XML property.

Example

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 = _ 
 
 Application.ActiveExplorer.CurrentView 
 
 
 
 ' 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 
 
 Next 
 
 
 
 ' Display a dialog box containing the concatenated 
 
 ' view field information. 
 
 MsgBox strOutput 
 
 End If 
 
End Sub 
 

See Also

Concepts

Outlook Object Model Reference

ViewFields Object Members