compareEndPoints Method
Compares an end point of an IHTMLTxtRange object with an end point of another IHTMLTxtRange object. Returns a Long that represents the comparison of the specified points.
expression.compareEndPoints(how, SourceRange)
expression Required. An expression that returns an IHTMLTxtRange object.
how Required String. Specifies how the two IHTMLTxtRange objects are to be compared. May be one of four values.
The String value of the how parameter can be one of the following:
Value | Description |
---|---|
StartToStart | Compares the start of the specified IHTMLTxtRange object with the start of the IHTMLTxtRange object specified in the SourceRange parameter. |
StartToEnd | Compares the start of the specified IHTMLTxtRange object with the end of the IHTMLTxtRange object specified in the SourceRange parameter. |
EndToStart | Compares the end of the specified IHTMLTxtRange object with the start of the IHTMLTxtRange object specified in the SourceRange parameter. |
EndToEnd | Compares the end of the specified IHTMLTxtRange object with the end of the IHTMLTxtRange object specified in the SourceRange parameter. |
SourceRange Required IHTMLTxtRange. The range with which to compare the initial range specified.
Remarks
The Long value returned for the compareEndPoints method can be one of the following values.
Value | Description |
---|---|
-1 | The end point of the object is further to the right than the end point of the IHTMLTxtRange object specified in the SourceRange parameter. |
0 | The end point of the object is at the same location as the end point of of the IHTMLTxtRange object specified in the SourceRange parameter. |
1 | The end point of the object is to the left of the end point of of the IHTMLTxtRange object specified in the SourceRange parameter. |
Example
The following example compares the selected range with the document and displays a message stating whether the selected range is at the beginning of the document or the end of the document.
Dim objDoc As IHTMLTxtRange
Dim objRange As IHTMLTxtRange
Set objDoc = ActiveDocument.body.createTextRange
Set objRange = ActiveDocument.Selection.createRange
If objRange.compareEndPoints("endtoend", objDoc) = 0 Then
MsgBox "The selected text is at the end of the page."
ElseIf objRange.compareEndPoints("starttostart", objDoc) = 0 Then
MsgBox "The selected text is at the beginning of the page."
Else
MsgBox "The selected text is in the middle of the page."
End If