Bookmark.Copy Method (String)

 

Creates a new Microsoft.Office.Interop.Word.Bookmark with the specified Name argument 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)

Bookmark Copy(
	string Name
)

Parameters

Name
Type: System.String

The name of the new bookmark.

The following code example adds a Bookmark control with text to the first paragraph, then copies the bookmark to the same location as the original bookmark. A message box displays the type and location of each bookmark.

This example is for a document-level customization.

private void BookmarkCopy()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "bookmark1";

    Word.Bookmark bookmark2 = bookmark1.Copy("bookmark2");

    MessageBox.Show("The range of bookmark1 starts at " + 
        bookmark1.Range.Start.ToString() + " and ends at " + 
        bookmark1.Range.End.ToString() + ".\n\n" + "The range " +
        "of bookmark2 starts at " + bookmark2.Range.Start.ToString()
        + " and ends at " + bookmark2.Range.End.ToString() + ".");
}
Return to top
Show: