Partager via


Bookmark.FormattedText, propriété

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 (dans Microsoft.Office.Tools.Word.dll)

Syntaxe

'Déclaration
Property FormattedText As Range
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];
}

Sécurité .NET Framework

Voir aussi

Référence

Bookmark Interface

Microsoft.Office.Tools.Word, espace de noms