共用方式為


Bookmark.FormattedText Property

Definition

Gets or sets a Range object that includes the formatted text in the Bookmark control.

public:
 property Microsoft::Office::Interop::Word::Range ^ FormattedText { Microsoft::Office::Interop::Word::Range ^ get(); void set(Microsoft::Office::Interop::Word::Range ^ value); };
public Microsoft.Office.Interop.Word.Range FormattedText { get; set; }
member this.FormattedText : Microsoft.Office.Interop.Word.Range with get, set
Public Property FormattedText As Range

Property Value

A Range object that includes the formatted text in the Bookmark control.

Examples

The following code example inserts text into the first paragraph and then formats the third word as bold. It then copies the third word (with formatting) to a Bookmark control.

This example is for a document-level customization.

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];
}
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

Remarks

When you set this property, the text in the Bookmark control is replaced with formatted text.

Applies to