Upravit

Sdílet prostřednictvím


Table.Sort method (Word)

Sorts the specified table.

Syntax

expression.Sort ( _ExcludeHeader_ , _FieldNumber_ , _SortFieldType_ , _SortOrder_ , _FieldNumber2_ , _SortFieldType2_ , _SortOrder2_ , _FieldNumber3_ , _SortFieldType3_ , _SortOrder3_ , _CaseSensitive_ , _BidiSort_ , _IgnoreThe_ , _IgnoreKashida_ , _IgnoreDiacritics_ , _IgnoreHe_ , _LanguageID_ )

expression Required. A variable that represents a 'Table' object.

Parameters

Name Required/Optional Data type Description
ExcludeHeader Optional Variant True to exclude the first row from the sort operation. The default value is False.
FieldNumber Optional Variant The first field by which to sort. Microsoft Word sorts by FieldNumber, then by FieldNumber2, and then by FieldNumber3.
SortFieldType Optional Variant The sort type for FieldNumber. Can be one of the WdSortFieldType constants. Some of these constants may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed. The default value is wdSortFieldAlphanumeric.
SortOrder Optional Variant The sorting order to use when sorting FieldNumber. Can be a WdSortOrder constant.
FieldNumber2 Optional Variant The second field by which to sort.
SortFieldType2 Optional Variant The sort type for FieldNumber2. Can be one of the WdSortFieldType constants. Some of these constants may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed. The default value is wdSortFieldAlphanumeric.
SortOrder2 Optional Variant The sorting order to use when sorting FieldNumber2. Can be one WdSortOrder constant.
FieldNumber3 Optional Variant The third field by which to sort.
SortFieldType3 Optional Variant The sort type for FieldNumber3. Can be one of the WdSortFieldType constants. Some of these constants may not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed. The default value is wdSortFieldAlphanumeric.
SortOrder3 Optional Variant The sorting order to use when sorting FieldNumber3. Can be one WdSortOrder constant.
CaseSensitive Optional Variant True to sort with case sensitivity. The default value is False.
BidiSort Optional Variant 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 Optional Variant 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 Optional Variant 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 Optional Variant 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 Optional Variant 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 Optional Variant Specifies the sorting language. Can be one of the WdLanguageID constants. Refer to the Object Browser for a list of the WdLanguageID constants.

Example

This example sorts the first table in the active document, excluding the heading row.

Sub NewTableSort() 
 ActiveDocument.Tables(1).Sort ExcludeHeader:=True 
End Sub

See also

Table Object

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.