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)

Syntax

'Declaration
Function Copy ( _
    Name As String _
) As Bookmark
Bookmark Copy(
    string Name
)

Parameters

Return Value

Type: Microsoft.Office.Interop.Word.Bookmark
A Microsoft.Office.Interop.Word.Bookmark object.

Remarks

The new bookmark is a Microsoft.Office.Interop.Word.Bookmark object rather than a Microsoft.Office.Tools.Word.Bookmark control.

Examples

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 Sub BookmarkCopy()

    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
        Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")
    Bookmark1.Text = "Bookmark1" 

    Dim Bookmark2 As Word.Bookmark = Bookmark1.Copy("Bookmark2")

    MessageBox.Show("The range of Bookmark1 starts at " & _
        Bookmark1.Range.Start.ToString & " and ends at " & _
        Bookmark1.Range.End.ToString & "." & vbLf & "The range " & _
        "of Bookmark2 starts at " & Bookmark2.Range.Start.ToString & _
        " and ends at " & Bookmark2.Range.End.ToString & ".")

End Sub
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() + ".");
}

.NET Framework Security

See Also

Reference

Bookmark Interface

Copy Overload

Microsoft.Office.Tools.Word Namespace