Word 2000

I have a simple macro that populates an array with bookmark names by reading
the contents of the Bookmarks collection. The only problem is that it fills
the array with the bookmark names in alphabetical order, and I need them
listed in the order in which they appear in the document from top to bottom.
Is there a way to sort the Bookmarks collection by location, and then use
that sorted list to populate an array?

-- Tom

MT DOJ Help Desk

Making the world a safer place.

Re: Listing Bookmark By Location in Document by Jezebel

Jezebel
Fri Jun 25 02:32:40 CDT 2004

You can determine the location by checking the Bookmark.Range.Start property
for each bookmark. You'll still have to sort the bookmarks yourself: either
sort them as you go by maintaining parallel arrays of start positions and
names, or read them all into a collection and then sort.




"MT DOJ Help Desk" <NoEmail@Please.com> wrote in message
news:%231nN5IoWEHA.384@TK2MSFTNGP10.phx.gbl...
> Word 2000
>
> I have a simple macro that populates an array with bookmark names by
reading
> the contents of the Bookmarks collection. The only problem is that it
fills
> the array with the bookmark names in alphabetical order, and I need them
> listed in the order in which they appear in the document from top to
bottom.
> Is there a way to sort the Bookmarks collection by location, and then use
> that sorted list to populate an array?
>
> -- Tom
>
> MT DOJ Help Desk
>
> Making the world a safer place.
>
>



Re: Listing Bookmark By Location in Document by Jonathan

Jonathan
Fri Jun 25 02:29:52 CDT 2004


"MT DOJ Help Desk" <NoEmail@Please.com> wrote in message
news:%231nN5IoWEHA.384@TK2MSFTNGP10.phx.gbl...
> Word 2000
>
> I have a simple macro that populates an array with bookmark names by
reading
> the contents of the Bookmarks collection. The only problem is that it
fills
> the array with the bookmark names in alphabetical order, and I need them
> listed in the order in which they appear in the document from top to
bottom.
> Is there a way to sort the Bookmarks collection by location, and then use
> that sorted list to populate an array?

Hi Tom

This goes through the bookmarks alphabetically

Dim oBookmark
For Each oBookmark in ActiveDocument.Bookmarks
'your code here
Next oBookmark

and this goes through the booknmarks in the order they appear in the
document

Dim oBookmark
For Each oBookmark in ActiveDocument.Range.Bookmarks
'your code here
Next oBookmark


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup


Re: Listing Bookmark By Location in Document by MT

MT
Fri Jun 25 21:11:02 CDT 2004

Jonathan,

Thanks for your help. I knew there had to be a way to do it, but I wasn't
having much luck finding it in the online Help.

-- Tom

MT DOJ Help Desk

Making the world a safer place.
"Jonathan West" <jwest@mvps.org> wrote in message
news:uVQtFloWEHA.3800@TK2MSFTNGP11.phx.gbl...
>
> "MT DOJ Help Desk" <NoEmail@Please.com> wrote in message
> news:%231nN5IoWEHA.384@TK2MSFTNGP10.phx.gbl...
> > Word 2000
> >
> > I have a simple macro that populates an array with bookmark names by
> reading
> > the contents of the Bookmarks collection. The only problem is that it
> fills
> > the array with the bookmark names in alphabetical order, and I need them
> > listed in the order in which they appear in the document from top to
> bottom.
> > Is there a way to sort the Bookmarks collection by location, and then
use
> > that sorted list to populate an array?
>
> Hi Tom
>
> This goes through the bookmarks alphabetically
>
> Dim oBookmark
> For Each oBookmark in ActiveDocument.Bookmarks
> 'your code here
> Next oBookmark
>
> and this goes through the booknmarks in the order they appear in the
> document
>
> Dim oBookmark
> For Each oBookmark in ActiveDocument.Range.Bookmarks
> 'your code here
> Next oBookmark
>
>
> --
> Regards
> Jonathan West - Word MVP
> www.intelligentdocuments.co.uk
> Please reply to the newsgroup
>