Bookmark.FormattedText Property
Gets or sets a Range object that includes the formatted text in the Bookmark control.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)
Syntax
'Declaration
Property FormattedText As Range
Range FormattedText { get; set; }
Property Value
Type: Range
A Range object that includes the formatted text in the Bookmark control.
Remarks
When you set this property, the text in the Bookmark control is replaced with formatted text.
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 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 Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.