Choosing paper size (NOT DEFAULT sizes) in excel vba

Question 1

xlPaperUser is a User-Defined paper size that is assigned a constant value of 256. If this has not been defined, it may throw an error.

Question 2

There is no way to create custom paper sizes in Excel, however you can create custom paper sizes on many printers. Under Page Setup, click the Options button. This will bring up the printer properties dialog box. Change your paper size to a custom size using this dialog box and click OK.

Then in Excel run this: MsgBox PageSetup.PaperSize. This will give you the new constant value assigned to that paper size in Excel. Then change .PaperSize = xlPaperUser in your macro to .PaperSize = & whatever the constant is that you just found.

Question 3

.PrintArea takes a string input, not a range. Change your line to ActiveSheet.PageSetup.PrintArea = Range("Img").Address and it should work.

Leave a Comment