Selection.Sort (Word)

Sorts the paragraphs in the specified selection.

Sort (ExcludeHeader, FieldNumber, SortFieldType, SortOrder, FieldNumber2, SortFieldType2, SortOrder2, FieldNumber3, SortFieldType3, SortOrder3, SortColumn, Separator, CaseSensitive, BidiSort, IgnoreThe, IgnoreKashida, IgnoreDiacritics, IgnoreHe, LanguageID, SubFieldNumber, SubFieldNumber2, SubFieldNumber3)


Sub NewParagraphSort() 
 Dim newDoc As Document 
 Set newDoc = Documents.Add 
 newDoc.Content.InsertAfter "pear" & Chr(13) _ 
 & "zucchini" & Chr(13) & "apple" & Chr(13) 
 newDoc.Content.Sort SortOrder:=wdSortOrderAscending 
End Sub

Arguments

Optional arguments

The following arguments are optional

ExcludeHeader (Boolean) - True to exclude the first row or paragraph header from the sort operation. The default value is False.

FieldNumber (Field) - The first field by which to sort.

SortFieldType (WdSortFieldType) - The sort type for FieldNumber. Can be one of the WdSortFieldType constants. The default value is wdSortFieldAlphanumeric. Some of the WdSortFieldType constants may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.


Possible values are

wdSortFieldAlphanumeric Alphanumeric order.
wdSortFieldDate Date order.
wdSortFieldJapanJIS Japanese JIS order.
wdSortFieldKoreaKS Korean KS order.
wdSortFieldNumeric Numeric order.
wdSortFieldStroke Stroke order.
wdSortFieldSyllable Syllable order.

SortOrder (WdSortOrder) - The sorting order to use when sorting FieldNumber2. Can be one WdSortOrder constant.The default value is wdSortOrderAscending.

Possible return values are wdSortOrderAscending - Ascending order. Default, wdSortOrderDescending - Descending order.

FieldNumber2 (Integer) - The second field by which to sort.

SortFieldType2 (WdSortFieldType) - The sort type for FieldNumber2. Can be one of the WdSortFieldType constants. The default value is wdSortFieldAlphanumeric. Some of the WdSortFieldType constants may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.


Possible values are

wdSortFieldAlphanumeric Alphanumeric order.
wdSortFieldDate Date order.
wdSortFieldJapanJIS Japanese JIS order.
wdSortFieldKoreaKS Korean KS order.
wdSortFieldNumeric Numeric order.
wdSortFieldStroke Stroke order.
wdSortFieldSyllable Syllable order.

SortOrder2

FieldNumber3 (Integer) - The third field by which to sort.

SortFieldType3 (WdSortFieldType) - The sort type for FieldNumber3. Can be one of the WdSortFieldType constants. The default value is wdSortFieldAlphanumeric. Some of the WdSortFieldType constants may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.


Possible values are

wdSortFieldAlphanumeric Alphanumeric order.
wdSortFieldDate Date order.
wdSortFieldJapanJIS Japanese JIS order.
wdSortFieldKoreaKS Korean KS order.
wdSortFieldNumeric Numeric order.
wdSortFieldStroke Stroke order.
wdSortFieldSyllable Syllable order.

SortOrder3 (WdSortOrder) - The sorting order to use when sorting FieldNumber3. Can be one WdSortOrder constant.The default value is wdSortOrderAscending.

Possible return values are wdSortOrderAscending - Ascending order. Default, wdSortOrderDescending - Descending order.

SortColumn

Separator (String) - The type of field separator.

CaseSensitive (Boolean) - True to sort with case sensitivity. The default value is False.

BidiSort (Boolean) - True to sort based on right-to-left language rules. This argument may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.

IgnoreThe (Boolean) - True to ignore the Arabic character alef lam when sorting right-to-left language text. This argument may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.

IgnoreKashida (Boolean) - True to ignore kashidas when sorting right-to-left language text. This argument may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.

IgnoreDiacritics (Boolean) - True to ignore bidirectional control characters when sorting right-to-left language text. This argument may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.

IgnoreHe (Boolean) - True to ignore the Hebrew character he when sorting right-to-left language text. This argument may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.

LanguageID (WdLanguageID) - Specifies the sorting language. Can be one of the WdLanguageID constants.

Here you can find possible values for WdLanguageID

SubFieldNumber (Integer) - A secondary field number by which to sort.

SubFieldNumber2 (Integer) - A secondary field number by which to sort.

SubFieldNumber3 (Integer) - A secondary field number by which to sort.