WD: Macros to Find Automatic (Soft) Page Breaks
ID: 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 95, versions 7.0, 7.0a
-
Microsoft Word for the Macintosh, versions 6.0, 6.0.1
SUMMARY
To search for "hard" (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 "soft" (automatic) page breaks
within a document. The macro examples in the "More Information" 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 "as is" 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 = "WhereYouWere"
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 "An automatic page break precedes page " + p$ + "."
End If
p = p + 1
Wend
EditGoTo .Destination = "WhereYouWere"
EditBookmark .Name = "WhereYouWere", .Delete
End Sub
To replace soft page breaks with hard page breaks throughout your
document, replace the following macro line
MsgBox "An automatic page break precedes page" + p$ + "."
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 = "WhereYouWere"
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 "An automatic page break precedes page" + p$ + "."
End If
p = p + 1
Wend
EditGoTo .Destination = "WhereYouWere"
InsertBookmark .Name = "WhereYouWere", .Delete
End Sub
To replace soft page breaks with hard page breaks throughout your
document, change the following macro line
MsgBox "An automatic page break precedes page" + p$ + "."
to the following:
InsertBreak .Type=0
REFERENCES
"Microsoft Word for Windows User's Guide," version 2.0, pages 260-266
"Using WordBasic" by WexTech Systems, Inc. and Microsoft Corporation,
Microsoft Press, 1992.
Additional query words:
pagination manual
Keywords : kbprint wordnt kbmacroexample winword macword word6 winword2 word7 word95 macword5 macword6
Version : MACINTOSH:6.0,6.0.1; WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a
Platform : MACINTOSH WINDOWS
Issue type : kbhowto