Bookmark.Duplicate Property

 

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

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

Range Duplicate { get; }

Property Value

Type: Microsoft.Office.Interop.Word.Range

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

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.

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.

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");
    }
}
Return to top
Show: