Microsoft Knowledge Base Email Alertz

(291298) - If you run a Microsoft Visual Basic for Applications macro that attempts to set or get the page setup properties for any sheet in a workbook, you may receive either of the following error messages Run-time error '1004': Unable to set the x property of...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 291298 - Last Review: January 2, 2007 - Revision: 3.0

You cannot use page setup properties in Excel if no printers were installed

This article was previously published under Q291298
For a Microsoft Excel 2000 version of this article, see 213516  (http://kbalertz.com/Feedback.aspx?kbNumber=213516/ ) .
For a Microsoft Excel 98 version of this article, see 182243  (http://kbalertz.com/Feedback.aspx?kbNumber=182243/ ) .
For a Microsoft Excel 97 and earlier versions of Excel version of this article, see 172320  (http://kbalertz.com/Feedback.aspx?kbNumber=172320/ ) .

SYMPTOMS

When you run a Microsoft Visual Basic for Applications macro that attempts to set or get the page setup properties for any sheet in a workbook in Microsoft Excel, you may receive either of the following error messages:
Run-time error '1004': Unable to set the x property of the PageSetup class
Run-time error '1004': Unable to get the x property of the PageSetup class
Note In these messages, x is any of the following words:
   BlackAndWhite        Order
   BottomMargin         Orientation
   CenterFooter         PaperSize
   CenterHeader         PrintArea
   CenterHorizontally   PrintComments
   CenterVertically     PrintGridlines
   ChartSize            PrintHeadings
   Draft                PrintNotes
   FirstPageNumber      PrintQuality
   FitToPagesTall       PrintTitleColumns
   FitToPagesWide       PrintTitleRows
   FooterMargin         RightFooter
   HeaderMargin         RightHeader
   LeftFooter           RightMargin
   LeftHeader           TopMargin
   LeftMargin           Zoom
				

CAUSE

This problem occurs when there are no printer drivers installed on your computer. Excel cannot set or get page setup properties if no printer drivers are installed.

RESOLUTION

To prevent this problem from occurring, install a printer driver on your computer. Use the Printers option in Control Panel to add and remove printer drivers.

MORE INFORMATION

In Excel, page setup properties are only available when you print or preview one or more sheets in a workbook. Because of this, you cannot change or return most page setup properties unless at least one printer driver is installed as the default printer.

If you click Page Setup on the File menu when no printer drivers are installed, you receive the following error message:
There are no printers installed. Use the Printers option in Control Panel to install a printer.
Just as you cannot access the Page Setup dialog box in this case, you cannot access the properties in the dialog box programmatically.

Note To open the Page Setup dialog box in Microsoft Office Excel 2007, press CTRL+F2, and then click Page Setup in the Print group.

APPLIES TO
  • Microsoft Office Excel 2007
  • Microsoft Office Excel 2003
  • Microsoft Excel 2002 Standard Edition
Keywords: 
kbexpertisebeginner kberrmsg kbprb kbprogramming KB291298
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Nagarajan - vnagaraj.alh1 NOSPAM-AT-NOSPAM ashokleyland.com Reported as Irrelevant  
Written: 6/3/2005 3:30 AM
This article says that this applied to Excel and VBA. While you have given a solution for Excel, there is no solution for VBA. I am not facing any problem with Excel, as the printers are installed properly. The problem must be some other. I require your solution. Thanks

thatsimonguy - thatsimonguy NOSPAM-AT-NOSPAM hotmail.com Report As Irrelevant  
Written: 2/28/2006 1:17 PM
This solution worked like a CHARM, I spent 3 days trying to fix this, I've looked everywhere else, adjusted registry keys, installed DLLs, changed security settings.. but in the end, installing the printer got me up and running, THANKS SO MUCH!

thats me Report As Irrelevant  
Written: 3/2/2006 7:37 AM
I am facing this problem while setting the pagesetup options via VBA. The problem occurs very randomly. Sometimes it run fine and sometime I get this error. If I open an excel sheet, the pagesetup property works fine. I have a default printer installed on machine. Don't know what exactly is causing the problem

Anonymous User Report As Irrelevant  
Written: 2/1/2008 11:41 AM
What a brilliant solution. Luckily I went looking for a hint such as this after only beating my head against it for 2 hours.