Posted: Mon Dec 24, 2007 1:45 am Post subject: Is cursor in a spanning bookmark? (Wd2003)
I have up to 40 bookmarks throughout a document with code generated names.
How can I determine whether the cursor is inside a spanning bookmark ( I
want to prevent the user inserting a bookmark inside a bookmark)
Posted: Mon Dec 24, 2007 3:45 am Post subject: Re: Is cursor in a spanning bookmark? (Wd2003)
Crude but might serve your need.
Sub Test()
Dim oBM As Bookmark
For Each oBM In ActiveDocument.Bookmarks
If Selection.Range.InRange(oBM.Range) Then
MsgBox "Sorry, you can't insert a bookmark here."
Exit For
End If
Next
End Sub
I have up to 40 bookmarks throughout a document with code generated
names. How can I determine whether the cursor is inside a spanning
bookmark ( I want to prevent the user inserting a bookmark inside a
bookmark)
Posted: Mon Dec 24, 2007 4:35 am Post subject: Re: Is cursor in a spanning bookmark? (Wd2003)
Thanks Greg
Works like a charm
Have a great Holiday break.
Ian B
"Greg Maxey" <gmaxey@mvps.oSCARrOMEOgOLF> wrote in message
news:%23%23%23Pj9dRIHA.5184@TK2MSFTNGP05.phx.gbl...
Quote:
Crude but might serve your need.
Sub Test()
Dim oBM As Bookmark
For Each oBM In ActiveDocument.Bookmarks
If Selection.Range.InRange(oBM.Range) Then
MsgBox "Sorry, you can't insert a bookmark here."
Exit For
End If
Next
End Sub
Ian B wrote:
I have up to 40 bookmarks throughout a document with code generated
names. How can I determine whether the cursor is inside a spanning
bookmark ( I want to prevent the user inserting a bookmark inside a
bookmark)
Posted: Mon Dec 24, 2007 8:07 am Post subject: Re: Is cursor in a spanning bookmark? (Wd2003)
How about:
Sub Test()
If Selection.Range.Bookmarks.Count > 0 Then MsgBox "Sorry, you can't insert a bookmark here."
End Sub
Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------
"Greg Maxey" <gmaxey@mvps.oSCARrOMEOgOLF> wrote in message news:%23%23%23Pj9dRIHA.5184@TK2MSFTNGP05.phx.gbl...
Quote:
Crude but might serve your need.
Sub Test()
Dim oBM As Bookmark
For Each oBM In ActiveDocument.Bookmarks
If Selection.Range.InRange(oBM.Range) Then
MsgBox "Sorry, you can't insert a bookmark here."
Exit For
End If
Next
End Sub
Ian B wrote:
I have up to 40 bookmarks throughout a document with code generated
names. How can I determine whether the cursor is inside a spanning
bookmark ( I want to prevent the user inserting a bookmark inside a
bookmark)
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum