Class OrderField (Outlook VBA)

The class OrderField represents an order field, used to sort information in a view. To use a OrderField class variable it first needs to be instantiated, for example


Dim ofd as OrderField
Set ofd = Session.CreateSharingItem.Move.Views(1).GroupByFields(Index:=1)

For Each

Here is an example of processing the OrderField items in a collection.


Dim ofdSortField As OrderField
For Each ofdSortField In Session.CreateSharingItem.Move.Views(1).SortFields
	
Next ofdSortField

Class

Returns an OlObjectClass constant indicating the object's class. Here you can find possible values for OlObjectClass.


Dim oocsClass As OlObjectClass
oocsClass = Session.CreateSharingItem.Move.Views(1).GroupByFields(1).Class

IsDescending

Returns or sets a Boolean value that indicates whether the contents of the OrderField object are sorted in descending order.

If this property is set to True, the contents of the property referenced by the OrderField object are sorted in descending order; otherwise, the contents are sorted in ascending order.


Session.CreateSharingItem.Move.Views(1).GroupByFields(1).IsDescending = True

Session

Returns the NameSpace object for the current session.

The Session property and the GetNamespace method can be used interchangeably to obtain the NameSpace object for the current session. Both members serve the same purpose. For example, the following statements perform the same function:

ViewXMLSchemaName

Returns a String value that represents the XML schema name for the property referenced by the OrderField object.

The value of this property contains the name of the property as it is included within the XML definition of the view containing the ViewField object. This value may not match the name used to refer to the property when the OrderField object was defined.


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