This documentation is archived and is not being maintained.

Bookmark.SelectionChange Event


Occurs when the selection inside the Bookmark control changes.

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

event SelectionEventHandler SelectionChange

This event is raised when the selection changes to or within the Bookmark control.

The following code example adds a Bookmark control with text to the document and then creates a SelectionChange event handler. A message box is displayed when the cursor is moved within the bookmark.

This example is for a document-level customization.

Microsoft.Office.Tools.Word.Bookmark bookmark5;

private void BookmarkSelectionChange()
    bookmark5 = this.Controls.AddBookmark(this.Paragraphs[1]
        .Range, "bookmark5");
    bookmark5.Text = "This is a sample bookmark.";
    bookmark5.SelectionChange += new Microsoft.Office.Tools.Word.SelectionEventHandler(bookmark5_SelectionChange);

void bookmark5_SelectionChange(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e)
    MessageBox.Show("The selection has changed within bookmark1.");
Return to top