ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   PageSetup changes not working in VBA (https://www.excelbanter.com/excel-programming/397591-pagesetup-changes-not-working-vba.html)

[email protected]

PageSetup changes not working in VBA
 
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


[email protected]

PageSetup changes not working in VBA
 
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



All times are GMT +1. The time now is 08:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com