WD: Macros to Find Automatic (Soft) Page BreaksLast reviewed: February 18, 1998Article ID: Q96375 |
The information in this article applies to:
SUMMARYTo 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 INFORMATIONSoft 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 SubTo 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=0NOTE: 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 SubTo 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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |