Microsoft KB Archive/129775

= Run-time Error '1005': Setting PrintArea Property =

Article ID: 129775

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 95a
 * Microsoft Excel 95 Standard Edition
 * Microsoft Excel 5.0c
 * Microsoft Excel 5.0 Standard Edition
 * Microsoft Excel 5.0 Standard Edition
 * Microsoft Excel 5.0a for Macintosh
 * Microsoft Excel 5.0 for Macintosh

-



This article was previously published under Q129775



SYMPTOMS
When you use the PrintArea property in a Microsoft Visual Basic for Applications macro to define a print area in the versions of Microsoft Excel listed at the beginning of this article, you may receive one of the following error messages:

Run-time error '1005':

Name is not defined" error message:

-or-

Run-time error '1005':



CAUSE
This problem occurs if the following conditions are true:   You run a Visual Basic macro with a line of code similar to the following: ActiveSheet.PageSetup.PrintArea = "A1:A7" -and-

 The reference used is a relative reference (using the dollar sign ($) symbols).



WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements. To work around this problem, define a print area by using the following line of code: ActiveSheet.PageSetup.PrintArea = "$A$1:$A$7" Because only one dollar sign is required, any of the following references will also work with the PrintArea property:    $A$1:$A$7 $A1:A7 A$1:A7 $A$1:A7 A1:$A7 A1:$A$7 A1:A$7



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Excel 97 for Windows and Microsoft Excel 98 Macintosh Edition.



MORE INFORMATION
For more information about the PrintArea property, click Search in the Visual Basic Reference and type:

print area

Additional query words: 5.00c print area vba XL7 XL5 XL

Keywords: kbbug kbenv kbprogramming kbcode KB129775

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.