Bookmark.IsEqual Method
Determines if the Bookmark control to which this method is applied is equal to the range specified by the Range argument.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)
Syntax
'Declaration
Function IsEqual ( _
Range As Range _
) As Boolean
bool IsEqual(
Range Range
)
Parameters
- Range
Type: Microsoft.Office.Interop.Word.Range
The Range object that is compared with the Bookmark control.
Return Value
Type: System.Boolean
true if the Bookmark control to which this method is applied is equal to the range specified by the Range argument; otherwise, false.
Remarks
This method compares the starting and ending character positions, as well as the story type. If all three of these items are the same for both objects, the objects are equal.
Optional Parameters
For information on optional parameters, see Optional Parameters in Office Solutions.
Examples
The following code example adds a Bookmark control with text to the document and checks to find out whether or not the range of the bookmark is equal to the range of the first paragraph.
This example is for a document-level customization.
Private Sub BookmarkIsEqual()
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.InsertAfter(" This is additional text.")
If Bookmark1.IsEqual(Me.Paragraphs(1).Range) Then
MessageBox.Show("The bookmark's range is equal to " _
& "the range of the first paragraph.")
Else
MessageBox.Show("The bookmark's range is not equal to " _
& "the range of the first paragraph.")
End If
End Sub
private void BookmarkIsEqual()
{
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.InsertAfter(" This is additional text.");
if (bookmark1.IsEqual(this.Paragraphs[1].Range))
{
MessageBox.Show("The bookmark's range is equal to "+
"the range of the first paragraph.");
}
else
{
MessageBox.Show("The bookmark's range is not equal to " +
"the range of the first paragraph.");
}
}
.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.