M
MT DOJ Help Desk
I have the following code (It's a test routine, so the code may be a bit
rough).
Sub TestBookmarkName()
NumBookmarks = Selection.Bookmarks.Count
For Counter = 1 To NumBookmarks
BookmarkName = ActiveDocument.Range.Bookmarks(Counter)
If Left(BookmarkName, 6) = "Record" Then
BookmarkNumber =
ActiveDocument.Bookmarks(BookmarkName).Range.BookmarkID + 1
BookmarkName = ActiveDocument.Bookmarks(BookmarkNumber)
Selection.GoTo what:=wdGoToBookmark, Name:=BookmarkName
End If
Next
End Sub
This works well, but with one problem--it gets the next bookmark as listed
by bookmark name. What I need is for it to get the next bookmark as listed
by location. Give that the whole point is to find the next bookmark by
location, this is a problem. I've figured out a couple of ways that I
can work around this issue, but none are as simple as this code. It would
be ideal if I could find a command that will order the bookmark collection
by location. Is there a way to do that, or am I stuck with a more round
about solution?
rough).
Sub TestBookmarkName()
NumBookmarks = Selection.Bookmarks.Count
For Counter = 1 To NumBookmarks
BookmarkName = ActiveDocument.Range.Bookmarks(Counter)
If Left(BookmarkName, 6) = "Record" Then
BookmarkNumber =
ActiveDocument.Bookmarks(BookmarkName).Range.BookmarkID + 1
BookmarkName = ActiveDocument.Bookmarks(BookmarkNumber)
Selection.GoTo what:=wdGoToBookmark, Name:=BookmarkName
End If
Next
End Sub
This works well, but with one problem--it gets the next bookmark as listed
by bookmark name. What I need is for it to get the next bookmark as listed
by location. Give that the whole point is to find the next bookmark by
location, this is a problem. I've figured out a couple of ways that I
can work around this issue, but none are as simple as this code. It would
be ideal if I could find a command that will order the bookmark collection
by location. Is there a way to do that, or am I stuck with a more round
about solution?