Is there an easy way to set a range to all text between two styles?

M

Max Moor

Hi All,
I have a long document made up of many sections. Most of these start
with a 'Heading 1' header, followed by a number of subsection, each headed
by a 'Heading 2'.

For each section in the doc, I wnt to be able to select all of the
Heading 2 sub-sections in turn. Is there a simple way to set a Range or
Selection to them, without having to search for the individual headings and
set ranges "by hand?"
 
C

Cindy M -WordMVP-

Hi Max,
I have a long document made up of many sections. Most of these start
with a 'Heading 1' header, followed by a number of subsection, each headed
by a 'Heading 2'.

For each section in the doc, I wnt to be able to select all of the
Heading 2 sub-sections in turn. Is there a simple way to set a Range or
Selection to them, without having to search for the individual headings and
set ranges "by hand?"
Well, one way is to use a predefined bookmark. This is old, old stuff - not
really documented since the move to VBA - which means you have to actually be
IN the heading level in order for it to work (Selection). So, you can use Find
to move to the "next" of whichever heading style you need, then
Selection.Bookmarks("\HeadingLevel").Range

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
M

Max Moor

Hi Max,

Well, one way is to use a predefined bookmark. This is old, old stuff
- not really documented since the move to VBA - which means you have
to actually be IN the heading level in order for it to work
(Selection). So, you can use Find to move to the "next" of whichever
heading style you need, then
Selection.Bookmarks("\HeadingLevel").Range


That may be a good solution. Ultimately, I want the headings to be
bookmarked so I can use them as hyperlink sub-addresses anyway. Thanks,
Max
 

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