Step thru Bookmarks by location

J

Jim Dahlstrom

Thanks to any that respond.
Using Word 2002

My Word document has 407 bookmarks that are conditioned;
i.e. hidden, unhidden, filled in, and formatted; based on
customer input to an electronic input form. I want to
walk thru the 407 bookmarks by location (start with the
first bookmark in the document). All the code I have
attempted steps thru the bookmarks in alphabetical order,
i.e. Bookmarks(1) is the first one alphabetically.

I have tried the DefaultSorting Property, but per the vba
help definition -
"Returns or sets the sorting option for bookmark names
displayed in the Bookmark dialog box (Insert menu).
Read/write WdBookmarkSortBy.

Remarks
This property doesn't affect the order of Bookmark objects
in the Bookmarks collection."

How can I do this??


Jim D.
 
D

Doug Robbins - Word MVP

Hi Jim

Use

Dim i as Long
For i = 1 to ActiveDocument.Bookmarks.Count
ActiveDocument.Range.Bookmarks(i)
etc.
Next i

The bookmarks will then be dealt with in the order in which they appear in
the document, rather than by alphabetical order of the bookmark names.

--
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
 
J

Jim Dahlstrom

Doug,

Thanks -- Of course it worked as it should.

One of the primary areas that I feel weak in, and suspect
would be of tremendous benefit to understand, is the
utilization of "Range" (all aspects). I have been thru
the KB, Help, and some of the manuals but feel like I'm
missing the basic definition to which the more technical
information can be applied to. Can you, or anyone else,
identify a document or set that will take this beginner
thru the steps??

Thanks for all you do.

Jim D.
 
J

Jim Dahlstrom

Doug,

I apologize for the open ended question. The obvious
reply is "Get some Training."

I will ask a more specific question instead.

My code was just like yours without the ".Range". Can you
help me understand why the addition of ".Range" changes
the order?

Thanks for all you do
Jim D.
 
D

Doug Robbins - Word MVP

See "Working with Range Objects" in the Visual Basic Help File.

--
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