The information in this article applies to:
SYMPTOMSWhen you use the Location property or Location.Address of vertical or horizontal page breaks in a Microsoft Visual Basic for Applications macro, you may receive the following error message:
CAUSEThis problem may occur when the following conditions are true:
WORKAROUNDMicrosoft provides programming examples 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 article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.aspTo prevent this problem from occurring, add code to select the last cell used in the worksheet before the code uses the Location property of horizontal or vertical page breaks. For example, use the following code to select the end cell, use the Location property, and then reselect the original active cell: NOTE: There must be enough data in the worksheet to go below the second page break for this example to work. If there is no data, or the data stops before the second page break, the code fails with the error as stated.After the Location property is calculated, you may again select the original active cell. If you use code to scroll between the first and last cell, or select the last cell and immediately reselect the starting cell, the error may still occur. The screen must redraw and the Location property be calculated for the workaround to be effective. If you use the above code with
to prevent screen redraw, the problem still occurs.
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. MORE INFORMATION
If you use the Count method with the VPageBreaks or HPageBreaks property, you may get a result of zero. This occurs under the conditions listed in the "Cause" section. If a page break is visible, the Count method may give the correct answer. The Count method for vertical or horizontal page breaks may give the expected result if a page break is near the visible portion of the workbook window. The workaround given earlier can be used to get the expected count. REFERENCESFor more information about the Location property, from the Visual Basic Editor, click the
Office Assistant, type Location property, click Search, and
then click to view "Location property." Q176476 OFF: Office Assistant Not Answering Visual Basic QuestionsFor additional information about how to trap errors in a macro, click the article number below to view the article in the Microsoft Knowledge Base: Q141571 XL: How to Use 'On Error' to Handle Errors in a Macro Additional query words: XL97 vba
Keywords : kbdta OffVBA |
Last Reviewed: October 27, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |