Share via


Bookmark.Sort Method

Sorts the paragraphs in the Bookmark control.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

Syntax

'Declaration
Sub Sort ( _
    ByRef ExcludeHeader As Object, _
    ByRef FieldNumber As Object, _
    ByRef SortFieldType As Object, _
    ByRef SortOrder As Object, _
    ByRef FieldNumber2 As Object, _
    ByRef SortFieldType2 As Object, _
    ByRef SortOrder2 As Object, _
    ByRef FieldNumber3 As Object, _
    ByRef SortFieldType3 As Object, _
    ByRef SortOrder3 As Object, _
    ByRef SortColumn As Object, _
    ByRef Separator As Object, _
    ByRef CaseSensitive As Object, _
    ByRef BidiSort As Object, _
    ByRef IgnoreThe As Object, _
    ByRef IgnoreKashida As Object, _
    ByRef IgnoreDiacritics As Object, _
    ByRef IgnoreHe As Object, _
    ByRef LanguageID As Object _
)
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
)

Parameters

  • ExcludeHeader
    Type: System.Object%

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

  • FieldNumber
    Type: System.Object%

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

  • SortFieldType
    Type: System.Object%

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

  • SortOrder
    Type: System.Object%

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

  • FieldNumber2
    Type: System.Object%

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

  • SortFieldType2
    Type: System.Object%

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

  • SortOrder2
    Type: System.Object%

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

  • FieldNumber3
    Type: System.Object%

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

  • SortFieldType3
    Type: System.Object%

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

  • SortOrder3
    Type: System.Object%

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

  • CaseSensitive
    Type: System.Object%

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

  • BidiSort
    Type: System.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
    Type: System.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
    Type: System.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
    Type: System.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
    Type: System.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.

Remarks

Optional Parameters

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

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 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
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);
    }

.NET Framework Security

See Also

Reference

Bookmark Interface

Microsoft.Office.Tools.Word Namespace