DocumentBase.ClickAndTypeParagraphStyle 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置由“即点即输”功能应用于文档中文本的默认段落样式。
public object ClickAndTypeParagraphStyle { get; set; }
属性值
由“即点即输”功能应用于文档中文本的默认段落样式。
示例
下面的代码示例向前两个段落中添加文本,并将第一个段落的样式设置为纯文本,然后将设置 ClickAndTypeParagraphStyle 为纯文本。 若要使用此示例,请在 ThisDocument 文档级项目的类中运行它。
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.");
}
}
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
注解
若要设置此属性,请指定样式的本地名称、整数、 WdBuiltinStyle 常量或表示样式的对象。
如果 InUse 指定样式的属性设置为 false ,则会引发异常。