Page setup (less the splurge)

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Page setup (less the splurge)

Post by VegasNath »

I recorded a macro to set up the page to landscape, print to 1 page with 1 cm margins, this being my only criteria. Therefore I cut out all the eroneous splurge, with the following result.

Code: Select all

    Workbooks.Add
    
    ActiveWindow.Zoom = 70
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    ActiveSheet.PageSetup.PrintArea = ""
    With ActiveSheet.PageSetup
        .LeftMargin = Application.InchesToPoints(0.393700787401575)
        .RightMargin = Application.InchesToPoints(0.393700787401575)
        .TopMargin = Application.InchesToPoints(0.393700787401575)
        .BottomMargin = Application.InchesToPoints(0.393700787401575)
        .Orientation = xlLandscape
        .FitToPagesWide = 1
        .FitToPagesTall = 1
    End With
The result is not as expected in print preview, it shows on 6 pages. I cannot see what I have removed in error?

Thanks for any advice
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78512
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Page setup (less the splurge)

Post by HansV »

As is, the code isn't very useful, because it creates a blank new workbook in the first line Workbooks.Add, so there is nothing to print.

But you removed the line

.Zoom = False

somewhere between the last With ... End With. This line tells Excel to use the FitToPagesWide and FitToPagesTall properties; without the above line, those properties will be ignored.
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: Page setup (less the splurge)

Post by VegasNath »

Thanks Hans, that corrects the problem. I do create a load of data, but posting that would have been irrelevant. :smile:
:wales: Nathan :uk:
There's no place like home.....