Share via


Bookmark.Sort Method

Definition

Sorts the paragraphs in the Bookmark control.

public void Sort (ref object ExcludeHeader, ref object FieldNumber, ref object SortFieldType, ref object SortOrder, ref object FieldNumber2, ref object SortFieldType2, ref object SortOrder2, ref object FieldNumber3, ref object SortFieldType3, ref object SortOrder3, ref object SortColumn, ref object Separator, ref object CaseSensitive, ref object BidiSort, ref object IgnoreThe, ref object IgnoreKashida, ref object IgnoreDiacritics, ref object IgnoreHe, ref object LanguageID);
abstract member Sort : obj * obj * obj * obj * obj * obj * obj * obj * obj * obj * obj * obj * obj * obj * obj * obj * obj * obj * obj -> unit
Public Sub Sort (Optional ByRef ExcludeHeader As Object, Optional ByRef FieldNumber As Object, Optional ByRef SortFieldType As Object, Optional ByRef SortOrder As Object, Optional ByRef FieldNumber2 As Object, Optional ByRef SortFieldType2 As Object, Optional ByRef SortOrder2 As Object, Optional ByRef FieldNumber3 As Object, Optional ByRef SortFieldType3 As Object, Optional ByRef SortOrder3 As Object, Optional ByRef SortColumn As Object, Optional ByRef Separator As Object, Optional ByRef CaseSensitive As Object, Optional ByRef BidiSort As Object, Optional ByRef IgnoreThe As Object, Optional ByRef IgnoreKashida As Object, Optional ByRef IgnoreDiacritics As Object, Optional ByRef IgnoreHe As Object, Optional ByRef LanguageID As Object)

Parameters

ExcludeHeader
Object

true to exclude the first row or paragraph header from the sort operation. The default value is false.

FieldNumber
Object

The fields to sort by. Microsoft Office Word sorts by FieldNumber, then by FieldNumber2, and then by FieldNumber3.

SortFieldType
Object

The respective sort types for FieldNumber, FieldNumber2, and FieldNumber3. Can be one of the WdSortFieldType constants.

SortOrder
Object

The sorting order to use when sorting FieldNumber, FieldNumber2, and FieldNumber3. Can be one of the WdSortOrder constants.

FieldNumber2
Object

The fields to sort by. Microsoft Office Word sorts by FieldNumber, then by FieldNumber2, and then by FieldNumber3.

SortFieldType2
Object

The respective sort types for FieldNumber, FieldNumber2, and FieldNumber3. Can be one of the WdSortFieldType constants

SortOrder2
Object

The sorting order to use when sorting FieldNumber, FieldNumber2, and FieldNumber3. Can be one of the WdSortOrder constants.

FieldNumber3
Object

The fields to sort by. Microsoft Office Word sorts by FieldNumber, then by FieldNumber2, and then by FieldNumber3.

SortFieldType3
Object

The respective sort types for FieldNumber, FieldNumber2, and FieldNumber3. Can be one of the WdSortFieldType constants

SortOrder3
Object

The sorting order to use when sorting FieldNumber, FieldNumber2, and FieldNumber3. Can be one of the WdSortOrder constants.

SortColumn
Object

true to sort only the column specified by the Bookmark control.

Separator
Object

Object. The type of field separator. Can be one of the WdSortSeparator constants.

CaseSensitive
Object

true to sort with case sensitivity. The default value is false.

BidiSort
Object

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

IgnoreThe
Object

true to ignore the Arabic characters aleflam when sorting right-to-left language text. This argument might not be available to you, depending on the language support (U.S. English, for example) that you have selected or installed.

IgnoreKashida
Object

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

IgnoreDiacritics
Object

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

IgnoreHe
Object

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

LanguageID
Object

Specifies the sorting language. Can be one of the WdLanguageID constants.

Examples

The following code example adds a Bookmark control with a list of fruits and then sorts the list in ascending order.

This example is for a document-level customization.

private void BookmarkSort()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();

    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "Oranges" + "\n" + "Bananas" + "\n" +
        "Apples" + "\n" + "Pears";
    object SortOrder = Word.WdSortOrder.wdSortOrderAscending;
    bookmark1.Sort(ref missing, ref missing, ref missing,
        ref SortOrder, ref missing, ref missing, ref missing,
        ref missing, ref missing, ref missing, ref missing,
        ref missing, ref missing, ref missing, ref missing,
        ref missing, ref missing, ref missing, ref missing);
    }
Private Sub BookmarkSort()

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")

    Bookmark1.Text = "Oranges" & vbLf & "Bananas" & vbLf & _
        "Apples" & vbLf & "Pears"

    Dim SortOrder As Object = Word.WdSortOrder.wdSortOrderAscending
    Bookmark1.Sort(SortOrder:=Word.WdSortOrder.wdSortOrderAscending)

End Sub

Remarks

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to