Extend Selection to Bookmark

S

Sarah M

Hi,

Can anyone tell me if you can extend the selection to a
specific bookmark, I know you can extend a char,
word ,line etc. But I want it to extend to a specific
point in the doc.

OR

Is it possible to have a line selected and be able to tell
whether a named bookmark is contained in it or not.

What I am trying to do is run through the contents of the
doc, until a specific point. I don't want it to stop at a
word or phrase as the user can change the contents.
However it can be mandated that the user does not delete a
bookmark.

TIA

Sarah
 
D

Doug Robbins - Word MVP

Hi Sarah,

Use:

Dim myrange As Range
Set myrange = Selection.Range
myrange.End = ActiveDocument.Bookmarks("Test").Range.End
myrange.Select

Or

Dim CurrLine As Range, BM As Range
Set CurrLine = Selection.Bookmarks("\line").Range
Set BM = ActiveDocument.Bookmarks("Test").Range
If BM.Start > CurrLine.Start And BM.End < CurrLine.End Then
MsgBox "The bookmark is in the current line."
Else
MsgBox "The bookmark is not in the current line."
End If

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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