Set papersize with vba

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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
 
Upvote 0
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:
Upvote 0

Forum statistics

Threads
1,215,733
Messages
6,126,541
Members
449,316
Latest member
sravya

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
Back
Top