Thread: Find and insert
View Single Post
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
PamC PamC is offline
external usenet poster
 
Posts: 39
Default Find and insert


If the text at the start of the new section styles as a heading style, you
can modify the style to "page break before". If you have no headings or
unique paragraph styles that can be changed, you can use a macro to put the
page breaks in. I'm no macro maven. I just recorded this macro and then
added code to make it loop. There are many excellent macro writers
providing help to this list, so someone else may chime in with something
better. If you want to try my macro, please try it on a *copy* of your
document.

*******

Sub FindNewSection()
'
' Find new section Macro
'
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "-{3,}^013*^013*^013"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Do While Selection.Find.Found
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.InsertBreak Type:=wdPageBreak
Selection.Find.Execute
Loop
End Sub


*******

PamC

"Allison" wrote:

Word 2000, Windows XP SP2

Hi all,

I have a text document with hundreds of pages. I need to go through and
make sure that each new area begins a new page.

Each new area begins two lines after a row of hyphens. The row following
the row of hyphens varies, so I can't simply replace that row with the data
followed by a page break.

Any suggestions how to do this automatically or programmatically?

Sample of data:

end of prior section
------------- (entire row of hyphens)
more text here that varies
begin new section here

Thanks for your help.