Set papersize with vba

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,011
Office Version
  1. 2016
Platform
  1. Windows
<code class="lang-vb" style="line-height: 19px; -webkit-font-smoothing: auto; font-family: monospace, monospace; font-size: 0.875rem; border-radius: 2px; display: block; padding: 0px; border: 0px; direction: ltr; box-sizing: inherit;">
Code:
Worksheets([COLOR=#A31515]"Sheet1"[/COLOR]).PageSetup.PaperSize = xlPaperQuarto

I used this code trying to make sure my default papersize is used but I get runtime error 1004

Unable to set the pagesize property of the pagesetup class.

Any help?

Can I set for a postcard size?</code>
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

=ODIN=

Active Member
Joined
Dec 3, 2009
Messages
288
I got the same error as you using xlPaperQuarto. -- but it worked for a few other sizes.

Even though that is valid constant, I'm pretty sure that the ones you're actually allowed to use are controlled by what Printer (and printer driver) are installed on your computer. On my computer, if I try to change paper-size through the ribbon GUI, I only see like 5 sizes available -- I'd try this on your computer.


The MSN website has a note that reads:
[FONT=&quot]Note[/FONT][FONT=&quot] Some printers may not support all of these paper sizes.[/FONT]

https://docs.microsoft.com/en-us/office/vba/api/Excel.PageSetup.PaperSize
 

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,011
Office Version
  1. 2016
Platform
  1. Windows
Sure, I can access the Japan postcard size from the ribbon and since that name is spaced out I don't know how to get it work.


Also how does the xlPaperUser work?
 
Last edited:

Forum statistics

Threads
1,136,868
Messages
5,678,226
Members
419,754
Latest member
Sallylwy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top