XL: PageBreak Property Does Not Work as Expected

Last reviewed: September 2, 1997
Article ID: Q134731
The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for Windows NT, version 5.0
  • Microsoft Excel for Windows 95, version 7.0

SYMPTOMS

In Microsoft Excel, the Visual Basic, Applications Edition, PageBreak property may not return the correct addresses for all page breaks in a worksheet.

CAUSE

When 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.

WORKAROUND

Using 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

STATUS

Microsoft 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.

REFERENCES

For more information about the PageBreak property, click the Index tab in Microsoft Excel Help, type the following text

   pagebreak

and 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
Keywords : kbprg PgmOthr kbcode
Version : 5.00 5.00c 7.00
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.