Bookmark.FormattedText 属性

获取或设置一个 Range 对象,该对象包括 Bookmark 控件中的格式化文本。

命名空间:  Microsoft.Office.Tools.Word
程序集:  Microsoft.Office.Tools.Word(在 Microsoft.Office.Tools.Word.dll 中)

语法

声明
Property FormattedText As Range
Range FormattedText { get; set; }

属性值

类型:Microsoft.Office.Interop.Word.Range
一个 Range 对象,包括 Bookmark 控件中的格式化文本。

备注

在设置此属性时,会用格式化文本替换 Bookmark 控件中的文本。

示例

下面的代码示例向第一个段落插入文本,然后将第三个单词的格式设置为粗体。然后该代码将第三个单词(带格式设置)复制到一个 Bookmark 控件中。

此示例针对的是文档级自定义项。

Private Sub BookmarkFormattedText()

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Me.Paragraphs(1).Range.Text = "This is text in the " & "first paragraph."
    Me.Paragraphs(1).Range.Words(3).Bold = True

    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(2).Range, "Bookmark1")
    Bookmark1.FormattedText = Me.Paragraphs(1).Range.Words(3)

End Sub
private void BookmarkFormattedText()
{
    int WordTrue = 1;
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.InsertParagraphBefore();
    this.Paragraphs[1].Range.Text = "This is text in the "
        + "first paragraph.";
    this.Paragraphs[1].Range.Words[3].Bold = WordTrue;
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[2].Range,
        "bookmark1");
    bookmark1.FormattedText = this.Paragraphs[1].Range.Words[3];
}

.NET Framework 安全性

请参见

参考

Bookmark 接口

Microsoft.Office.Tools.Word 命名空间