Share via


SetSortOrder Method [Publisher 2003 VBA Language Reference]

Sets the sort order for mail merge data.

expression.SetSortOrder(SortField1, SortAscending1, SortField2, SortAscending2, SortField3, SortAscending3)

expression Required. An expression that returns one of the objects in the Applies To list.

SortField1  Optional String. The first field on which to sort the mail merge data. Default is an empty string.

SortAscending1  Optional Boolean. True (default) to perform an ascending sort on SortField1; False to perform a descending sort.

SortField2  Optional String. The second field on which to sort the mail merge data. Default is an empty string.

SortAscending2  Optional Boolean. True (default) to perform an ascending sort on SortField2; False to perform a descending sort.

SortField3  Optional String. The third field on which to sort the mail merge data. Default is an empty string.

SortAscending3  Optional Boolean. True (default) to perform an ascending sort on SortField3; False to perform a descending sort.

Example

The following example sorts mail merge data first on ZIP code in descending order, then on last name and first name in ascending order.

ActiveDocument.MailMerge.DataSource.SetSortOrder _
    SortField1:="ZIPCode", SortAscending1:=False, _
    SortField2:="LastName", SortField3:="FirstName"

Applies to | MailMergeDataSource Object