How to set 'Fit all columns on one page' in print tab
Asked Answered
T

1

25

The only thing I would want is to always set the 'Fit all columns on one page' setting when users open the Print tab in Excel.

And no, they don't want to do it themselves. What a surprise :)

Here is a screenshot of where that is in Excel 2013:enter image description here

Tried to look for some VBA code like the following but without success.

With Sheets("Print Letter").PageSetup .FitToPagesWide = 1 .FitToPagesTall = 1 End With

Tailor answered 9/9, 2014 at 9:25 Comment(2)
Are you looking for SetPrintArea??Airtight
For Office-JS API see --> #72917855Devilry
S
46

Try setting the .FitToPagesTall to False to be able to manually set the .FitToPagesWide property.

MSDN link

If this property is False, Microsoft Excel scales the worksheet according to the FitToPagesWide property. If the Zoom property is True, the FitToPagesTall property is ignored.

Sub PrintColumns()
    Application.PrintCommunication = False
    With Sheets("Print Letter").PageSetup
        .FitToPagesWide = 1
        .FitToPagesTall = False
    End With
    Application.PrintCommunication = True
End Sub
Strader answered 9/9, 2014 at 9:29 Comment(3)
Should I then add .Zoom = False just in case so it never ignores the FitToPagesTall property?Tailor
I just added ´Application.PrintCommunication = False´ to my code and that did the trick!Woodcock
.Zoom = False .FitToPagesWide = 1 .FitToPagesTall = False is working fine thanks.Booklover

© 2022 - 2024 — McMap. All rights reserved.