OrderField object (Outlook)

Represents an order field, used to sort information in a view.


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

Use the ViewXMLSchemaName property to obtain the name of the order field as referenced in the XML definition of the view.

OrderField objects contained in an OrderFields collection are applied to Outlook items displayed in the view in the order in which the objects are contained in the collection. For each OrderField object, use the IsDescending property to determine whether to sort the contents of the order field in ascending or descending order.


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

Private Sub DisplayTableViewSortFields() 
 Dim objTableView As TableView 
 Dim objOrderField As OrderField 
 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 OrderFields collection for 
 ' the table view, obtaining the label and the 
 ' XML schema name for each field used to sort 
 ' the items in the view. 
 For Each objOrderField In objTableView.SortFields 
 With objOrderField 
 strOutput = strOutput & .ColumnFormat.Label & _ 
 " (" & .ViewXMLSchemaName & ")" & vbCrLf 
 End With 
 ' Display a dialog box containing the concatenated 
 ' sort field information. 
 MsgBox strOutput 
 End If 
End Sub 



See also

Outlook Object Model Reference

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.