Expand Minimize

Bookmark.TextRetrievalMode Property

Gets or sets a TextRetrievalMode object that controls how text is retrieved from the Bookmark control.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

TextRetrievalMode TextRetrievalMode { get; set; }

Property Value

Type: Microsoft.Office.Interop.Word.TextRetrievalMode
A TextRetrievalMode object that controls how text is retrieved from the Bookmark control.

The following code example adds a Bookmark control with text to the document, hides the third word in the bookmark, and sets the TextRetrievalMode so that hidden text is not included. It then displays the text of the bookmark in a message box.

This example is for a document-level customization.

private void BookmarkTextRetrievalMode()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    int WordTrue = 1;
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "This is sample bookmark text.";
    bookmark1.Words[3].Font.Hidden = WordTrue;
    bookmark1.TextRetrievalMode.IncludeHiddenText = false;
    MessageBox.Show("The text in bookmark1 is: " + bookmark1.Text);
}

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft