Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

applying heading styles automatically

Status
Not open for further replies.

pluz

Instructor
Jan 26, 2004
20
US
Hello!
I have a bunch of txt files that have numbered paragraphs, e.g.,
Level 1 para starts with 1. Followed by text...
Level 2 para starts with 1.1. Followed by text...
Level 3 para starts with (a) Followed by text...
Level 4 para starts with (i) Followed by text...

I would like to know if someone can please help me with a Word macro that can find all 1., 2., 3. (through infinity??) etc. at the beginning of a paragraph in the active document and replace it with the Heading 1 style.
Then, look for 1.1, 1.2 (or 2.1, 2.2, depending on Level 1 number), etc. and replace it with Heading 2 style.
Then, look for (a), (b), (c), etc. and replace it with Heading 3 style, and so on.

This will save me countless hours of very tedious work. I'm hoping that you brilliant people can help me once again! Thanks.
 
Hi pluz,

Take a look at the AutoFormat feature (on the Format menu). You might have to do some global changes of style afterwards but it should do most of what you want.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
I tried that, but there was no consistency at all, i.e., both Heading styles and List styles were used throughout the document in the same level. Also, with AutoFormat, I still would need to apply the correct style and remove the hard typed numbers manually. Any other suggestions?
 
Hi pluz,

Well, if Autoformat isn't doing it, I would think there's something in there that's going to make it difficult to code for as well. It will create List styles but they can be changed - I don't know what inconsistencies you are getting so can't say much more.

You might be able to do at least some of it with global find/replace, for example to change all paragraphs which contain a parenthesized roman numeral (below 50 anyway) ..

Find: [blue](\([ivx]{1,}\))[/blue]
Replace: [blue]\1[/blue] and Style Heading 4
check Wildcards
Replace All

note that this will change all paragraphs which CONTAIN the string not just those which begin with it.

If that helps we can work out similar finds for some (maybe all) of your other triggers which, perhaps combined with autoformat, should get you there.

If that isn't of any help, perhaps you could send me a bigger sample than you've posted - (my handle here) at VBAExpress dot com


Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top