DocumentBase.ClickAndTypeParagraphStyle Property

 

Gets or sets the default paragraph style applied to text by the Click and Type feature in the document.

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

public object ClickAndTypeParagraphStyle { get; set; }

Property Value

Type: System.Object

The default paragraph style applied to text by the Click and Type feature in the document.

To set this property, specify the local name of the style, an integer, a T:Microsoft.Office.Interop.Word.WdBuiltinStyle constant, or an object that represents the style.

If the P:Microsoft.Office.Interop.Word.Style.InUse property for the specified style is set to false, an exception is thrown.

The following code example adds text to the first two paragraphs, styles the first paragraph as Plain Text, and then sets the ClickAndTypeParagraphStyle to Plain Text. To use this example, run it from the ThisDocument class in a document-level project.

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.");
    }
}
Return to top
Show: