vba 如何在打印选项卡中设置“在一页上显示所有列”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/25741049/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set 'Fit all columns on one page' in print tab
提问by Pepys
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.
当用户在 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:
这是 Excel 2013 中位置的屏幕截图:
Tried to look for some VBA code like the following but without success.
试图寻找一些像下面这样的 VBA 代码,但没有成功。
With Sheets("Print Letter").PageSetup
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
With Sheets("Print Letter").PageSetup
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
回答by
Try setting the .FitToPagesTallto Falseto be able to manually set the .FitToPagesWideproperty.
尝试设置.FitToPagesTall到False能够手动设置.FitToPagesWide属性。
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.
如果此属性为 False,Microsoft Excel 将根据 FitToPagesWide 属性缩放工作表。如果 Zoom 属性为 True,则忽略 FitToPagesTall 属性。
Sub PrintColumns()
    Application.PrintCommunication = False
    With Sheets("Print Letter").PageSetup
        .FitToPagesWide = 1
        .FitToPagesTall = False
    End With
    Application.PrintCommunication = True
End Sub

