inRange Method
Returns True if the IHTMLTxtRange object specified in the range argument is contained in the original range.
expression.inRange(range)
*expression * Required. An expression that returns an IHTMLTxtRange object.
range Required IHTMLTxtRange object.
Example
The following example takes an IHTMLTxtRange object, and then returns True if the current selection is contained within the specified IHTMLTxtRange or returns False if the current selection isn't contained within the specified IHTMLTxtRange.
Function IsInRange(objRange As IHTMLTxtRange) As Boolean
Dim objSelection As IHTMLTxtRange
Set objSelection = ActiveDocument.Selection.createRange
If objRange.inRange(objSelection) = False Then
IsInRange = False
Else
IsInRange = True
End If
End Function
Use the following example to call the preceding function.
Sub CallIsInRange()
Dim objRange As IHTMLTxtRange
Set objRange = ActiveDocument.body.createTextRange
MsgBox IsInRange(objRange)
End Sub
Applies to | IHTMLTxtRange Object