scroll problem navigating with bookmarks

S

Smallweed

I've set up an app in which the user moves through a Word document viewing
sections of text which have been named with bookmarks. My VBA code uses:
ActiveDocument.Bookmarks("mybookmark").Select

The problem is that this method of moving makes the screen scroll in such a
way to ensure the END of the bookmarked range is visible, rather than the
BEGINNING. My bookmarked sections (which can each include several pages of
text) have headings and it would be a lot better to be able to see them as
you move from bookmark to bookmark.

Any ideas? (We still use 2002/XP)
 
P

Pesach Shelnitz

Hi,

In your code, you can get the Range of the bookmark, set the end of the
range equal to the beginning, and then select the Range using the following
code.

Dim myRange As Range

Set myRange = ActiveDocument.Bookmarks("MyBookmark").Range
myRange.End = myRange.start
myRange.Select
 
S

Smallweed

Talk about a quick response! Thanks Pesach.
I added the line ActiveDocument.Bookmarks("MyBookmark").Range.Select at the
end of your code so that the bookmarked text is actually highlighted (which
is what I wanted) but your End=Start trick sorted the scrolling problem
beautifully...
 
Top