Share via


DocumentBase.ClickAndTypeParagraphStyle 屬性

取得或設定由文件的即點即書 (Click and Type) 功能套用至文字的預設段落樣式。

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

語法

'宣告
Public Property ClickAndTypeParagraphStyle As Object
public Object ClickAndTypeParagraphStyle { get; set; }

屬性值

型別:System.Object
由文件的即點即書 (Click and Type) 功能套用至文字的預設段落樣式。

備註

若要設定這個屬性,請指定樣式、整數、WdBuiltinStyle 常數,或代表樣式之物件的區域名稱。

如果所指定樣式的 InUse 屬性設定為 false,則會擲回例外狀況。

範例

下列程式碼範例會將文字加入至前兩個段落、將第一個段落的樣式設定為純文字,然後將 ClickAndTypeParagraphStyle 設定為純文字。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

Private Sub DocumentClickAndTypeParagraphStyle()

    Dim styleName As Object = "Plain Text"
    Me.Paragraphs(1).Range.InsertParagraphAfter()
    Me.Paragraphs(1).Range.InsertParagraphAfter()
    Me.Paragraphs(1).Range.Text = "This is sample text."
    Me.Paragraphs(2).Range.Text = "This is sample text."
    Me.Paragraphs(1).Range.Style = styleName

    If Me.Styles.Item(styleName).InUse Then
        Me.ClickAndTypeParagraphStyle = styleName
    Else
        MessageBox.Show(styleName & " is not in use yet.")
    End If

End Sub 
private void DocumentClickAndTypeParagraphStyle()
{

    object styleName = "Plain Text";
    this.Paragraphs[1].Range.InsertParagraphAfter();
    this.Paragraphs[1].Range.InsertParagraphAfter();
    this.Paragraphs[1].Range.Text = "This is sample text.";
    this.Paragraphs[2].Range.Text = "This is sample text.";
    this.Paragraphs[1].Range.set_Style(ref styleName);

    if (this.Styles.get_Item(ref styleName).InUse)
    {
        this.ClickAndTypeParagraphStyle = styleName;
    }
    else
    {
        MessageBox.Show(styleName + " is not in use yet.");
    }
}

.NET Framework 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間