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

Pepys picture Pepys · Sep 9, 2014 · Viewed 60.6k times · Source

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

Answer

user2140173 picture user2140173 · Sep 9, 2014

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