Computer Forum Forum Index
Register  FAQ Profile Log in to check your private messages Log in Register 

Is cursor in a spanning bookmark? (Wd2003)

 
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word vba general
View previous topic :: View next topic  
Author Message
Ian B
Guest





PostPosted: Mon Dec 24, 2007 1:45 am    Post subject: Is cursor in a spanning bookmark? (Wd2003) Reply with quote

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)

TIA

Ian B
Back to top
Google
Sponsor





PostPosted: Mon Dec 24, 2007 1:45 am    Post subject: Advertisement

Back to top
Greg Maxey
Guest





PostPosted: Mon Dec 24, 2007 3:45 am    Post subject: Re: Is cursor in a spanning bookmark? (Wd2003) Reply with 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

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Ian B wrote:
Quote:
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)

TIA

Ian B
Back to top
Ian B
Guest





PostPosted: Mon Dec 24, 2007 4:35 am    Post subject: Re: Is cursor in a spanning bookmark? (Wd2003) Reply with quote

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

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


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)

TIA

Ian B

Back to top
macropod
Guest





PostPosted: Mon Dec 24, 2007 8:07 am    Post subject: Re: Is cursor in a spanning bookmark? (Wd2003) Reply with quote

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

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


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)

TIA

Ian B

Back to top
Display posts from previous:   
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word vba general All times are GMT
Page 1 of 1

 
Jump to:  
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
Computer Forum