Share via

Replace Section Break not working

Anonymous
2012-07-09T15:32:10+00:00

Last week, I used Word 2010 replace to change all section breaks (^b) to manual page breaks (^m).   I'm doing this in a document generated with Mail Merge, in which I want consecutive page numbers. 

Today, this DOES NOT WORK.  Strangely, the Find function finds all of ^b.  BUT, the replace function does not find any of them.  Yes, I have selected "All", etc. 

Please advise soonest.

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Jay Freedman 207.7K Reputation points Volunteer Moderator
2015-07-22T23:53:33+00:00

The key to the problem in the document that you posted is that each section break is followed immediately by a table. I found a hint in post #11 by Klaus Linke in this thread: "Are the section breaks right before tables? In that case Find/Replace doesn't work properly, and you might have to write a macro or do it by hand." He was writing in 2008 about Word 2007, but nothing has changed. <sigh>

This macro will replace all the section breaks in your document with page breaks:

Sub ReplaceSectionBreaks()

    'reliably replace section breaks with page breaks

    'even if they're followed by tables

    Dim rg As Range

    Set rg = ActiveDocument.Range

    With rg.Find

        .Text = "^b"

        .Wrap = wdFindStop

        While .Execute

            rg.Delete

            rg.InsertBreak Type:=wdPageBreak

            rg.Collapse wdCollapseEnd

        Wend

    End With

End Sub

See http://www.gmayor.com/installing_macro.htm if needed.

Was this answer helpful?

10+ people found this answer helpful.
0 comments No comments

Answer accepted by question author

Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
2015-07-22T23:24:31+00:00

I am not sure why the Replace does not work as Find does locate the Section Breaks.

However, running a macro with the following code will replace the Section Breaks with Page Breaks:

Selection.HomeKey wdStory

Selection.Find.ClearFormatting

With Selection.Find

    Do While .Execute(FindText:="^b", MatchWildcards:=False, Forward:=True, Wrap:=wdFindStop) = True

        With Selection

            .Delete

            .InsertBreak Type:=wdPageBreak

        End With

    Loop

End With

Was this answer helpful?

0 comments No comments

Answer accepted by question author

Jay Freedman 207.7K Reputation points Volunteer Moderator
2012-07-09T16:53:27+00:00

When you say that Find finds the section breaks but Replace doesn't find them -- are you doing both of these in the Find and Replace dialog, or are you using the Search Document box in the Navigator pane to do the Find?

If it's the latter, the search options may be different for the two operations. In the Replace dialog, click the More button and make sure all the check boxes are cleared.

If that doesn't work, it may (odd as it seems) help to reboot Windows and try again.

Was this answer helpful?

0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2015-07-24T13:44:55+00:00

    Thank you Doug

    Thank you Jay

    Both of your solutions worked. Although, I am using the range version as I deal with a lengthy and large list of files.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-07-22T20:50:55+00:00

    Greetings Jay,

    I have the same problem with my word documents. I tried both in 2010 and 2013 version.

    There are section breaks (section break next page) at the bottom of each page. When I try to find (^b) and replace  (^m) using the replace dialog it does the same thing Chi Town Bob stated above.

    I tried a new document by inserting some lines with 3 pages with each page having a section break. It works just fine in my new document. I am wondering what is different in my source file that is generated from SAS.

    Link to my section break problem file:

    https://drive.google.com/file/d/0B41cph9KmzJnMEtJNnJJZ1hHaVE/view?usp=sharing

    Thanks

    Was this answer helpful?

    0 comments No comments