Microsoft KB Archive/96375

{|
 * width="100%"|

WD: Macros to Find Automatic (Soft) Page Breaks

 * }

Q96375

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
 * Microsoft Word for Windows, versions 7.0, 7.0a
 * Microsoft Word for the Macintosh, versions 6.0, 6.0.1

-

SUMMARY
To search for &quot;hard&quot; (manually inserted) page breaks and section breaks in a Word, click Find on the Edit menu, and type ^m (^d in versions of Word prior to 6.x) in the Find What box.

There is no search character to locate &quot;soft&quot; (automatic) page breaks within a document. The macro examples in the &quot;More Information&quot; section of this article can be used to locate automatic page breaks.

MORE INFORMATION
Soft page breaks are automatically inserted by Word when the end of the document page is reached. Any new text is automatically pushed to the next page. A soft page break also occurs before a paragraph formatted with the Page Break Before option selected in the Paragraph dialog box.

You can insert hard page breaks by pressing CTRL+ENTER(In Word for the Macintosh, option+return) or selecting the Page Break option button in the Insert Break dialog box.

The following macro examples examine the page breaks in a document and determine whether or not they are soft page breaks. The macro examples retrieve the total number of pages in the document and then move to each page break successively. By moving the selection to the left one character, the macro examples determine if the new selection is text or a hard page break. Document text has a character code greater than 31, and a hard page break is character number 12 or 14.

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code &quot;as is&quot; without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

  Sub MAIN EditBookmark .Name = &quot;WhereYouWere&quot; StartOfDocument ToolsRepaginate NumPages = SelInfo(4) p = 2 While p <= NumPages p$ = Str$(p) EditGoTo .Destination = p$        CharLeft 1 CurSel$ = Selection$ a = Asc(CurSel$) If a <> 12 And a <> 14 Or a < 31 Then MsgBox &quot;An automatic page break precedes page &quot; + p$ + &quot;.&quot; End If        p = p + 1 Wend EditGoTo .Destination = &quot;WhereYouWere&quot; EditBookmark .Name = &quot;WhereYouWere&quot;, .Delete End Sub To replace soft page breaks with hard page breaks throughout your document, replace the following macro line

MsgBox &quot;An automatic page break precedes page&quot; + p$ + &quot;.&quot; with the following two lines:

If SelInfo(13) <> - 1 Then CharRight 1 InsertBreak .Type=0 NOTE: The first of these two lines checks to see if the insertion point is in a table.

WordBasic - Word 2.x
  Sub MAIN InsertBookmark .Name = &quot;WhereYouWere&quot; StartOfDocument ToolsRepaginateNow NumPages = SelInfo(4) p = 2 While p <= NumPages p$ = Str$(p) EditGoTo .Destination = p$        CharLeft 1, 1 CurSel$ = Selection$ a = Asc(CurSel$) If a <> 12 And a <> 14 Or a > 31 Then MsgBox &quot;An automatic page break precedes page&quot; + p$ + &quot;.&quot; End If        p = p + 1 Wend EditGoTo .Destination = &quot;WhereYouWere&quot; InsertBookmark .Name = &quot;WhereYouWere&quot;, .Delete End Sub To replace soft page breaks with hard page breaks throughout your document, change the following macro line

MsgBox &quot;An automatic page break precedes page&quot; + p$ + &quot;.&quot; to the following:

InsertBreak .Type=0