PageSetup changes not working in VBA

D

david.j.winfield

I am trying to change the PageSetup using VBA, but it does not seem to
take the changes. I tried using both the XL4M method and the
standard .PageSetup. I seem to be able to set the print area, but not
the PaperSize or the Orientation. I have stepped through the code and
it does not error out, but the settings do not change in PageSetup
either. The worksheet is not protected.

Here are the two methods that I used (I put the code for PageSetupXL4M
into its own macro).

With Worksheets("Master Index").PageSetup
'With ActiveSheet.PageSetup
'.PrintHeadings = False
.Zoom = False
.Orientation = page_orientation
.CenterHorizontally = False
.CenterVertically = False
.PaperSize = page_size
.FitToPagesWide = 1
.PrintErrors = xlPrintErrorsDisplayed
End With

PageSetupXL4M PrintHeadings:=False, _
Zoom:=False, _
Orientation:=page_orientation, _
CenterHorizontally:=False, _
CenterVertically:=False, _
PaperSize:=page_size

I have tried setting page_orientation to both the string "xlPortrait"
and the number xlPortrait (1).


Thanks for your help,
David
 
D

david.j.winfield

for some reason xlPaper11x17 does not change my paper size but
xlPaperTabloid does. I tried putting in numerical values and noticed
that some of the numbers do not change the size. For example
xlPaper11x17 gives 17, but if I give the number 17 directly nothing
happens. 11x17 and Tabloid are both listed as options for my printer.

Is one of these options more likely to work then the other? Will one
work on one computer and if I send it to another will it not work
there? How to I ensure that the worksheet will behave the same across
different computers/printers?

Should I set the page size in VBA then check to see if it took (also
in vba) if it did not try the other?

Thanks,
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top