formating sections in a loop

S

shark102

hello

I have a document with many many short sections which looks like that:

---------section break (continuous)------------
text ^p
text ^p
text ^p
---------section break (continuous)------------
text ^p
text ^p
text ^p
text ^p
---------section break (continuous)------------
text ^p
text ^p
---------section break (continuous)------------
text ^p
text ^p
text ^p

etc.... - there are usually 3 sections per page.

It goes on for many pages. The thing I need to do is to format each section
as 'keep with next' so that sections are not split between pages when
printing. I recorded macro using find ^12*^12 and formatting one paragraph
but cant loop it. Do not know where to put while or loop or do until, still
do not know enough about VBA.

Any help appreciated.

Thanks
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?c2hhcmsxMDI=?=,

May I suggest you set up a STYLE with the properties you require and apply the
style to the entire document? That will be quicker than looping through all
the paragraphs in the document.

But to loop through all paragraphs, in all sections, it would go something
like this:

For each sec in ActiveDocument.Sections
For each para in sec.Range.Paragraphs

Next
Next
I have a document with many many short sections which looks like that:

---------section break (continuous)------------
text ^p
text ^p
text ^p
---------section break (continuous)------------
text ^p
text ^p
text ^p
text ^p
---------section break (continuous)------------
text ^p
text ^p
---------section break (continuous)------------
text ^p
text ^p
text ^p

etc.... - there are usually 3 sections per page.

It goes on for many pages. The thing I need to do is to format each section
as 'keep with next' so that sections are not split between pages when
printing. I recorded macro using find ^12*^12 and formatting one paragraph
but cant loop it. Do not know where to put while or loop or do until, still
do not know enough about VBA.

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 :)
 
D

Dave Lett

Hi shark102,

You can also do a search/replace for paragraphs (^p) if you want a _quick_
fix.

Specifically, open the Find and Replace dialog box.
In the Find what box, type (without quotations) "^p".
In the Replace with box, type (without quotations) "^p".
If you don't have access to the Format button, then click More.
Click Format, click Paragraph, and click the Line and Page Breaks tab.
Select the Keep with next check box. Click OK. Click Replace All.

HTH,
Dave
 

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