The following function will return False or True as a result of checking if the beginning of your selection is between 2 bookmarks passed by name to the function. It doesn't matter in which order you pass bookmarks name.
Function BetweenBookmarks(FirstBookmarkName, SecondBookmarkName)
If Selection.Start > ActiveDocument.Bookmarks(FirstBookmarkName).Range.End _
And _
Selection.End < ActiveDocument.Bookmarks(SecondBookmarkName).Range.Start Then
BetweenBookmarks = True
ElseIf Selection.Start > ActiveDocument.Bookmarks(SecondBookmarkName).Range.End _
And _
Selection.End < ActiveDocument.Bookmarks(FirstBookmarkName).Range.Start Then
BetweenBookmarks = True
Else
BetweenBookmarks = False
End If
End Function
Function can be called in this way:
Debug.Print BetweenBookmarks("First", "Second")
Debug.Print BetweenBookmarks("Second", "First")
You could make some other modification on your own by changing .End
and .Start
properties within the function.