Extracting text using style names

J

josetg

Hi All,

Please guide me to the correct functions...

If I used Outline view to create a document, then how do I use VBA to
extract text of a specified style and at a certain level?

For example, say this is the structure:

<A Heading1 Title>
p1 normal text formatted in body text style.
<B Heading2 Title>
p2 normal text formatted in body text style.
<C Heading3 Title>
p3 normal text formatted in body text style.

<D Heading3 Title>
p4 normal text formatted in body text style.


In this case, by specifying body text style, and the level as
A-B-C can i quickly extract the text in p3?

Also, I should be able to specify body text style and level as A-B and
extract text in p2.


Many thanks
Jose
 
K

Klaus Linke

Hi Jose,

What part do you have problems with? Or are you asking for the "best" way
to go about it?

You could loop all paragraphs in the range you want to collect from.

Keep a watch variable set to the current outline level, and update this
watch variable when you loop a heading.

If you loop a body text paragraph (wdOutlineLevelBodyText), and the watch
variable is 3 (for the p3 paragraphs) or 2 (for the p2 paragraphs), extract
the text.

Regards,
Klaus
 

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