Solved

Why have I just started getting the error "Unable to set the PaperSize property of the PageSetup class?

Posted on 2008-10-01
11
1,097 Views
Last Modified: 2012-06-27
Recently on some of my time tested VBA Excel macros, I have started getting the message "Unable to set the PaperSize property of the PageSetup class" This error message targets the statement:

.Papersize = xlPaperLetter

Here is the code within which the staement is failing:

With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = "$A:$A"
        .LeftMargin = application.InchesToPoints(0.1)
        .RightMargin = application.InchesToPoints(0.1)
        .TopMargin = application.InchesToPoints(0.44)
        .BottomMargin = application.InchesToPoints(0.25)
        .HeaderMargin = application.InchesToPoints(0)
        .FooterMargin = application.InchesToPoints(0)
        .PrintQuality = 600
        .CenterHorizontally = True
        .CenterVertically = False
        .Orientation = xlLandscape
        .PaperSize = xlPaperLetter
        .Order = xlDownThenOver
        .Zoom = 100
    End With
   
I am unaware of any wholesale changes made to the printers lately and no changes have been made to my computer. That's why I find this such a mystery. Any ideas?

Thanks,

Taduh
0
Comment
Question by:taduh
  • 5
  • 4
  • 2
11 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 22619702
Is your active printer the same? Can you manually print to letter size using it?
0
 

Author Comment

by:taduh
ID: 22623280
rorya,

Yes, my active printer is the same and I can manually print to letter size using it.

taduh
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 22625953
And is this in Excel VBA or in VBScript (you have put it in both zones)?
0
 

Author Comment

by:taduh
ID: 22626985
Its actually in Excel VBA.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22628715
What happens if you delete your connection to the printer, recreate it, and set it as the default?  Or if you select a different default printer to test with?  Maybe your printer connection is corrupt....

Regards,

Rob.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:taduh
ID: 22633532
Rob,

I tried your suggestion and it did not help. I did find out that they have been migrating our printers from 32 bit to 64 bit over the last several months. Could this have anything to do with it? If so, do you know of anything I can do still be able to specify paper size via my VBA macro?
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22666238
It probably is due to new drivers......

What happens if you connect to that printers IP address, by going to:
Control Panel --> Printers and Faxes --> Add Printer --> Local Printer (do not automatically detect my printer) --> Create a new port --> Standard TCP/IP port --> Enter the printer's IP Address --> Select a driver (maybe try 32 and 64 bit drivers separately)

Then if you try to print to that, what happens with the different driver versions?

Regards,

Rob.
0
 

Author Comment

by:taduh
ID: 22668252
Rob,

How do I tell whther a driver is 32-bit or 64-bit?

taduh
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 22673170
Hi, try getting a 32bit driver in a folder on your computer to install the driver from when you get to the "Select a driver" section, and click "Have Disk" and use that location.  Get a 64bit driver and do the same thing for a second test.

I think that should work.

Regards,

Rob.
0
 

Author Closing Comment

by:taduh
ID: 31502165
Rob,
Youu were on the right track. It had to do with the drivers. I had IT set me up a "printer" using the 32-bit driver and now I reference that printer in my code. Thanks and sorry for the delay.  
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22782282
That's great.  Thanks for the grade.

Regards,

Rob.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now