determining if IP is in a bookmark range

L

Larry

If you have a bookmark X which is more than one character in size, how
would you determine if the cursor is located somewhere in that bookmark?

I tried this, but this only works if Selection.Range is exactly equal to
the range of the bookmark.

If Selection.Range = ActiveDocument.Bookmarks("X").Range Then MsgBox
"Yes"

Thanks,
Larry
 
L

Larry

I figured out a way to do it, though it's crude and I'd rather find
something more elegant:

If Selection.Range.Start > ActiveDocument.Bookmarks("X").Range.Start - 1
And _
Selection.Range.Start < ActiveDocument.Bookmarks("X").Range.End +
1 Then
MsgBox "Yes"
Else
MsgBox "no"
End If
 
G

Greg

Larry,

How about:

Sub Test()
If Selection.InRange(ActiveDocument.Bookmarks("X").Range) Then
MsgBox "Yes"
Else
MsgBox "no"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top