PDA

View Full Version : Solved: Determin whether the cursor is in a bookmark



evamads
04-30-2009, 02:46 AM
Hi All,

Is there a way to determin whether the cursor is located in a bookmark in Word? :banghead:

macropod
05-11-2009, 09:24 PM
Hi evamads,

You could use a macro like:
Sub TestSelection()
Dim oBkMk As Bookmark
Dim strResult
With ActiveDocument
strResult = ""
For Each oBkMk In .Bookmarks
If Selection.Range.Start <= oBkMk.Range.End _
And Selection.Range.End >= oBkMk.Range.Start Then _
strResult = strResult & " " & oBkMk.Name
Next
End With
If strResult = "" Then strResult = "None!"
MsgBox "Bookmarks spanning the selection:" & vbCrLf & Trim(strResult), , "Bookmark Reporter"
End Sub

evamads
05-12-2009, 12:07 AM
Hi macropod,

Thanks a lot - just what I was looking for :thumb