Bookmark.Duplicate Property

Definition

Gets a read-only Range object that represents all the properties of the Bookmark control.

C#
public Microsoft.Office.Interop.Word.Range Duplicate { get; }

Property Value

A read-only Range object that represents all the properties of the Bookmark control.

Examples

The following code example adds a Bookmark control with text to the first paragraph and sets the text to bold. It then returns a range from the Duplicate property of the Bookmark and displays a message box indicating that the range contains the same properties as the bookmark.

This example is for a document-level customization.

C#
private void BookmarkDuplicate()
{
    int WordTrue = 1;
    this.Paragraphs[1].Range.InsertParagraphBefore();
    Microsoft.Office.Tools.Word.Bookmark bookmark1 =
        this.Controls.AddBookmark(this.Paragraphs[1].Range,
        "bookmark1");
    bookmark1.Text = "This is sample bookmark text.";
    bookmark1.Bold = WordTrue;
                
    Word.Range myRange = bookmark1.Duplicate;
    if (myRange.Font.Bold == WordTrue)
    {
        MessageBox.Show("MyRange is bold because Bookmark1 has"
            + " its Bold property set to true");
    }
    else
    {
        MessageBox.Show("MyRange is not bold because Bookmark1 has"
            + " its Bold property set to false");
    }
}

Remarks

You can assign the object returned by the Duplicate property to another Range to apply those settings all at once. Before assigning the duplicate object to another Range, you can change any of the properties of the duplicate object without affecting the original.

By duplicating a Range object, you can change the starting or ending character position of the duplicate range without changing the original range.

Applies to

Product Versions
Visual Studio Tools for Office 2017, 2019, 2022