Share via


DocumentBase.StyleSortMethod 屬性

取得或設定值,指定排序 [樣式] 工作窗格中的樣式時所使用的排序方法。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

語法

'宣告
Public Property StyleSortMethod As WdStyleSort
public WdStyleSort StyleSortMethod { get; set; }

屬性值

型別:Microsoft.Office.Interop.Word.WdStyleSort
其中一個 WdStyleSort 值。

範例

下列程式碼範例會顯示 [樣式] 工作窗格的目前排序方法。 接下來,如果目前排序方法不是依照字母順序的排序方法,程式碼就會向使用者顯示訊息,告知即將修改這個排序方法,然後將該排序方法修改為依照字母的排序順序。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

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 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間