Bookmark.Select Method (2007 System)

Selects the Bookmark control.

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

Syntax

'Declaration
Public Sub Select
'Usage
Dim instance As Bookmark

instance.Select()
public void Select()
public:
void Select()
public function Select()

Remarks

After using this method, use the Selection property to work with the selected Bookmark control.

Examples

The following code example adds a Bookmark control with the text to the document and then creates a BeforeDoubleClick event handler. The text within the bookmark is selected when the Bookmark control is double-clicked.

This example is for a document-level customization.

WithEvents Bookmark2 As Microsoft.Office.Tools.Word.Bookmark

Private Sub BookmarkBeforeDoubleClick()

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Bookmark2 = Me.Controls.AddBookmark(Me.Paragraphs(1).Range, _
        "Bookmark2")
    Bookmark2.Text = "This is a sample bookmark." 

End Sub 

Private Sub Bookmark2_BeforeDoubleClick(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ClickEventArgs) _
    Handles Bookmark2.BeforeDoubleClick

    Bookmark2.Select()
    e.Cancel = True 
End Sub
Microsoft.Office.Tools.Word.Bookmark bookmark2;

private void BookmarkBeforeDoubleClick()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    bookmark2 = this.Controls.AddBookmark(this.Paragraphs[1]
        .Range, "bookmark2");
    bookmark2.Text = "This is a sample bookmark.";
    bookmark2.BeforeDoubleClick += new Microsoft.Office.Tools
        .Word.ClickEventHandler(bookmark2_BeforeDoubleClick);
}

void bookmark2_BeforeDoubleClick(object sender, 
    Microsoft.Office.Tools.Word.ClickEventArgs e)
{
    bookmark2.Select();
    e.Cancel = true;
}

.NET Framework Security

See Also

Reference

Bookmark Class

Bookmark Members

Microsoft.Office.Tools.Word Namespace