Поделиться через


DocumentBase.StyleSortMethod Property

Gets or sets a value that specifies the sort method to use when sorting styles in the Styles task pane.

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

Syntax

'Declaration
Public Property StyleSortMethod As WdStyleSort
    Get
    Set
public WdStyleSort StyleSortMethod { get; set; }

Property Value

Type: Microsoft.Office.Interop.Word.WdStyleSort
One of the WdStyleSort values.

Examples

The following code example displays the current sort method for the Styles task pane. Next, if the current sort method is not the alphabetical sort method, the code displays a message that informs the user that the sort method is about to be modified, and then modifies the sort method to the alphabetical sort order. To use this example, run it from the ThisDocument class in a document-level project.

Private Sub SetStyleSortOrder()
    MessageBox.Show("Current sort method for the styles task pane is: " _
            + Me.StyleSortMethod.ToString())
    If Me.StyleSortMethod <> Word.WdStyleSort.wdStyleSortByName Then
        MessageBox.Show("Changing sort method to " _
            + Word.WdStyleSort.wdStyleSortByName.ToString() _
            + " to sort styles alphabetically in the styles " _
            + "task pane.")
        Me.StyleSortMethod = Word.WdStyleSort.wdStyleSortByName
    End If
End Sub
private void SetStyleSortOrder()
{
    MessageBox.Show("Current sort method for the styles task pane is: " 
        + this.StyleSortMethod.ToString());
    if (this.StyleSortMethod != Word.WdStyleSort.wdStyleSortByName)
    {
        MessageBox.Show("Changing sort method to "
            + Word.WdStyleSort.wdStyleSortByName.ToString()
            + " to sort styles alphabetically in the styles "
            + "task pane.");
        this.StyleSortMethod = Word.WdStyleSort.wdStyleSortByName;
    }            
}

.NET Framework Security

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace