共用方式為


Bookmark.IsEqual(Range) Method

Definition

Determines if the Bookmark control to which this method is applied is equal to the range specified by the Range argument.

public:
 bool IsEqual(Microsoft::Office::Interop::Word::Range ^ Range);
public bool IsEqual (Microsoft.Office.Interop.Word.Range Range);
abstract member IsEqual : Microsoft.Office.Interop.Word.Range -> bool
Public Function IsEqual (Range As Range) As Boolean

Parameters

Range
Range

The Range object that is compared with the Bookmark control.

Returns

true if the Bookmark control to which this method is applied is equal to the range specified by the Range argument; otherwise, false.

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 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.");
    }
}
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

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.

Applies to