Bookmark.Duplicate Property (2007 System)
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.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)
Syntax
'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property Duplicate As Range
'Usage
Dim instance As Bookmark
Dim value As Range
value = instance.Duplicate
[BrowsableAttribute(false)]
public Range Duplicate { get; }
[BrowsableAttribute(false)]
public:
property Range^ Duplicate {
Range^ get ();
}
public function get Duplicate () : Range
Property Value
Type: Range
A read-only Range object that represents all the properties of the Bookmark control.
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.
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.
Private Sub BookmarkDuplicate()
Me.Paragraphs(1).Range.InsertParagraphBefore()
Dim Bookmark1 As Microsoft.Office.Tools.Word.Bookmark = _
Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark1")
Bookmark1.Text = "This is sample bookmark text."
Bookmark1.Bold = True
Dim myRange As Word.Range = Bookmark1.Duplicate
If myRange.Font.Bold = True Then
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")
End If
End Sub
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");
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.