所选内容。 Sort 方法 (Word)Selection.Sort method (Word)

对指定的所选内容中的段落进行排序。Sorts the paragraphs in the specified selection.

语法Syntax

表达式排序( _ExcludeHeader_ , _FieldNumber_ , _SortFieldType_ , _SortOrder_ , _FieldNumber2_ , _SortFieldType2_ , _SortOrder2_ , _FieldNumber3_ , _SortFieldType3_ , _SortOrder3_ , _SortColumn_ , _Separator_ , _CaseSensitive_ , _BidiSort_ , _IgnoreThe_ , _IgnoreKashida_ , _IgnoreDiacritics_ , _IgnoreHe_ , _LanguageID_ , _SubFieldNumber_ , _SubFieldNumber2_ , _SubFieldNumber3_ )expression.Sort ( _ExcludeHeader_ , _FieldNumber_ , _SortFieldType_ , _SortOrder_ , _FieldNumber2_ , _SortFieldType2_ , _SortOrder2_ , _FieldNumber3_ , _SortFieldType3_ , _SortOrder3_ , _SortColumn_ , _Separator_ , _CaseSensitive_ , _BidiSort_ , _IgnoreThe_ , _IgnoreKashida_ , _IgnoreDiacritics_ , _IgnoreHe_ , _LanguageID_ , _SubFieldNumber_ , _SubFieldNumber2_ , _SubFieldNumber3_ )

expression:必需。expression Required. 表示 Selection 对象的变量。A variable that represents a Selection object.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
ExcludeHeaderExcludeHeader 可选Optional VariantVariant 要排除第一个行或段落标题进行排序。True to exclude the first row or paragraph header from the sort operation. 默认值为 FalseThe default value is False.
Sp.fieldnumberFieldNumber 可选Optional VariantVariant 用于排序的第一个域。The first field by which to sort.
SortFieldTypeSortFieldType 可选Optional VariantVariant 数字排序类型。The sort type for FieldNumber. 可以是WdSortFieldType常量之一。Can be one of the WdSortFieldType constants. 默认值是 wdSortFieldAlphanumericThe default value is wdSortFieldAlphanumeric. 一些 WdSortFieldType 常量可能不可用,这取决于您所选择或安装的语言支持 (例如美国英语)。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.
SortOrderSortOrder 可选Optional VariantVariant 对数字进行排序时使用的排序顺序。The sorting order to use when sorting FieldNumber. 可以是一个**WdSortOrder** 常量。默认值为wdSortOrderAscendingCan be one WdSortOrder constant.The default value is wdSortOrderAscending.
FieldNumber2FieldNumber2 可选Optional VariantVariant 用于排序的第二个域。The second field by which to sort.
SortFieldType2SortFieldType2 可选Optional VariantVariant 排序类型为 FieldNumber2 的。The sort type for FieldNumber2. 可以是WdSortFieldType常量之一。Can be one of the WdSortFieldType constants. 默认值是 wdSortFieldAlphanumericThe default value is wdSortFieldAlphanumeric. 一些 WdSortFieldType 常量可能不可用,这取决于您所选择或安装的语言支持 (例如美国英语)。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.
SortOrderSortOrder 可选Optional VariantVariant 排序顺序排序 FieldNumber2 时使用。The sorting order to use when sorting FieldNumber2. 可以是一个**WdSortOrder** 常量。默认值为wdSortOrderAscendingCan be one WdSortOrder constant.The default value is wdSortOrderAscending.
SortColumn2SortColumn2 可选Optional VariantVariant 选择 对象所指定的列进行排序。True to sort only the column specified by the Selection object.
SeparatorSeparator 可选Optional VariantVariant 域分隔符的类型。The type of field separator.
FieldNumber3FieldNumber3 可选Optional VariantVariant 用于排序的第三个域。The third field by which to sort.
SortFieldType3SortFieldType3 可选Optional VariantVariant 排序类型为 FieldNumber3 的。The sort type for FieldNumber3. 可以是WdSortFieldType常量之一。Can be one of the WdSortFieldType constants. 默认值是 wdSortFieldAlphanumericThe default value is wdSortFieldAlphanumeric. 一些 WdSortFieldType 常量可能不可用,这取决于您所选择或安装的语言支持 (例如美国英语)。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.
SortOrder3SortOrder3 可选Optional VariantVariant 排序顺序排序 FieldNumber3 时使用。The sorting order to use when sorting FieldNumber3. 可以是一个**WdSortOrder** 常量。默认值为wdSortOrderAscendingCan be one WdSortOrder constant.The default value is wdSortOrderAscending.
CaseSensitiveCaseSensitive 可选Optional VariantVariant 要排序时区分大小写。True to sort with case sensitivity. 默认值为 FalseThe default value is False.
BidiSortBidiSort 可选Optional VariantVariant 要排序按照从右到左语言规则。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.
IgnoreTheIgnoreThe 可选Optional VariantVariant 要忽略阿拉伯语字符 alef lam 从右向左的语言文本进行排序时。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.
IgnoreKashidaIgnoreKashida 可选Optional VariantVariant 从右向左的语言文本进行排序时忽略 kashida。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.
IgnoreDiacriticsIgnoreDiacritics 可选Optional VariantVariant 从右向左的语言文本进行排序时忽略双向控制字符。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.
IgnoreHeIgnoreHe 可选Optional VariantVariant 要忽略希伯来字符 he 从右向左的语言文本进行排序时。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.
LanguageIDLanguageID 可选Optional VariantVariant 指定排序语言。Specifies the sorting language. 可以是WdLanguageID常量之一。Can be one of the WdLanguageID constants.
SubFieldNumberSubFieldNumber 可选Optional VariantVariant 用于排序的二级域编号。A secondary field number by which to sort.
SubFieldNumber2SubFieldNumber2 可选Optional VariantVariant 用于排序的二级域编号。A secondary field number by which to sort.
SubFieldNumber3SubFieldNumber3 可选Optional VariantVariant 用于排序的二级域编号。A secondary field number by which to sort.

示例Example

以下示例在新文档中插入三行文本,然后按字母数字升序对这些行进行排序。This example inserts three lines of text into a new document and then sorts the lines in ascending alphanumeric order

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

另请参阅See also

Selection 对象Selection Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.