How do I remove consecutive multiple page breaks?

G

Guest

I'm logging a report to a .doc from another application, which inserts
extraneous page breaks. Is there a way to set up a macro to remove
extraneous, consecutive page breaks, while leaving only 1 page break?

Thanks,
Barry Klusky
 
J

Jay Freedman

bsklusky said:
I'm logging a report to a .doc from another application, which inserts
extraneous page breaks. Is there a way to set up a macro to remove
extraneous, consecutive page breaks, while leaving only 1 page break?

Thanks,
Barry Klusky

The simple manual, non-macro procedure:
The code for a manual page break in the Find/Replace dialog is ^m . Open the
dialog, enter ^m^m in the Find What box and only one ^m in the Replace
With box, and click the Replace All button. Keep clicking Replace All until
it says there were 0 replacements.

As a macro (slightly different approach, using wildcards):
Sub RemoveMultiplePageBreaks()
Dim oRg As Range
Set oRg = ActiveDocument.Range
With oRg.Find
.ClearFormatting
.Text = "([^12])[^12]{1,}"
.Replacement.Text = "\1"
.Format = False
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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