Bookmark.Copy Method

Creates a new Microsoft.Office.Interop.Word.Bookmark in the same location as the existing Microsoft.Office.Tools.Word.Bookmark control.

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

void Copy()

The following code example adds a Bookmark control to the document and then creates a BeforeRightClick event handler. When the Bookmark control is right-clicked, the text within the bookmark is copied to the Clipboard.

This example is for a document-level customization.

Microsoft.Office.Tools.Word.Bookmark bookmark3;

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

void bookmark3_BeforeRightClick(object sender, 
    Microsoft.Office.Tools.Word.ClickEventArgs e)
{
    bookmark3.Copy();
    e.Cancel = true;
}

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