This documentation is archived and is not being maintained.

MailMergeDataSource.SetSortOrder Method

Office 2007
Sets the sort order for mail merge data.

Syntax

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

expression   A variable that represents a MailMergeDataSource object.

Parameters

NameRequired/OptionalData TypeDescription
SortField1OptionalStringThe first field on which to sort the mail merge data. Default is an empty string.
SortAscending1OptionalBooleanTrue (default) to perform an ascending sort on SortField1; False to perform a descending sort.
SortField2OptionalStringThe second field on which to sort the mail merge data. Default is an empty string.
SortAscending2OptionalBooleanTrue (default) to perform an ascending sort on SortField2; False to perform a descending sort.
SortField3OptionalStringThe third field on which to sort the mail merge data. Default is an empty string.
SortAscending3OptionalBooleanTrue (default) to perform an ascending sort on SortField3; False to perform a descending sort.

Example

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

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



Show: