Partager via


Bookmark.FormattedText, propriété (System 2007)

Mise à jour : novembre 2007

Obtient ou définit un objet Range qui inclut le texte mis en forme du contrôle Bookmark.

Espace de noms :  Microsoft.Office.Tools.Word
Assembly :  Microsoft.Office.Tools.Word.v9.0 (dans Microsoft.Office.Tools.Word.v9.0.dll)

Syntaxe

<BrowsableAttribute(False)> _
Public Property FormattedText As Range

Dim instance As Bookmark
Dim value As Range

value = instance.FormattedText

instance.FormattedText = value
[BrowsableAttribute(false)]
public Range FormattedText { get; set; }

Valeur de propriété

Type : Microsoft.Office.Interop.Word.Range

Objet Range qui inclut le texte mis en forme dans le contrôle Bookmark.

Notes

Lorsque vous définissez cette propriété, le texte du contrôle Bookmark est remplacé par le texte mis en forme.

Exemples

L'exemple de code suivant insère du texte dans le premier paragraphe, puis met le troisième mot en gras. Ensuite, il copie le troisième mot (avec sa mise en forme) dans un contrôle Bookmark.

Cet exemple illustre une personnalisation au niveau du document.

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

Autorisations

Voir aussi

Référence

Bookmark, classe

Membres Bookmark

Microsoft.Office.Tools.Word, espace de noms