XL: PageBreak Property Does Not Work as ExpectedLast reviewed: September 2, 1997Article ID: Q134731 |
The information in this article applies to:
SYMPTOMSIn Microsoft Excel, the Visual Basic, Applications Edition, PageBreak property may not return the correct addresses for all page breaks in a worksheet.
CAUSEWhen you insert a manual page break, all automatic page break addresses are changed accordingly. A Visual Basic procedure that verifies the addresses of page breaks will return only information about the manual page break addresses and the original automatic page break addresses; new automatic page break addresses will not be returned.
WORKAROUNDUsing the Microsoft Excel 4.0 macro function "GET.DOCUMENT(64)" will return the address of all page breaks in the document. The following macro shows demonstrates how to use this Microsoft Excel 4.0 macro function in a Visual Basic for Applications procedure. The following procedure will return an array of all page breaks in a document. Microsoft provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose.
Sub TestPageBreaks() Dim NumberOfBreaks As Integer 'Total Number of Page Breaks in a Document Dim Counter As Integer 'Generic Counter Dim BreaksArray() 'Array of Row numbers of each page break 'Get Number of PageBreaks NumberOfBreaks = _ Application.ExecuteExcel4Macro("COLUMNS(GET.DOCUMENT(64))") 'Resize Array to Hold All PageBreaks Row Numbers ReDim BreaksArray(1 To NumberOfBreaks) 'Loop to fill the Array with PageBreaks Row Numbers For Counter = 1 To NumberOfBreaks BreaksArray(Counter) = _ Application _ .ExecuteExcel4Macro("INDEX(GET.DOCUMENT(64)," & _ Counter & ")") Next 'Loop to Show All PageBreaks Row Numbers For Counter = 1 To NumberOfBreaks MsgBox "There is a Page Break at Row: " & BreaksArray(Counter) Next End Sub STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
REFERENCESFor more information about the PageBreak property, click the Index tab in Microsoft Excel Help, type the following text
pagebreakand then double-click the selected text to go to the "PageBreak Property" topic.
|
Additional query words: 5.00 5.00c 7.00 PageBreak Automatic Page Break
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |