我正在尝试更改Excel工作表的纸张尺寸和纸张方向, 代码运行时没有任何错误,但Excel中没有任何变化
这是一段代码:
Private Sub doCompare()
Dim xlApp As Excel.Application = Nothing
Dim DEs As Excel.Worksheet = Nothing
Dim Rws As Excel.Worksheet = Nothing
Dim ewb As Excel.Workbook = Nothing
XLapp = New Excel.Application
ewb = XLapp.Workbooks.Open("xxxxxxx0.xls")
DEs = ewb.Worksheets("Data Entry")
Rws = ewb.Worksheets("Comparing Results")
'Do something with these worksheets
'Now trying to change default settings. Code copied from Excel macro
xlApp.PrintCommunication = False
Rws.PageSetup.PrintArea = ""
DEs.PageSetup.PrintArea = ""
With Rws.PageSetup
.Orientation = Excel.XlPageOrientation.xlLandscape
.PaperSize = Excel.XlPaperSize.xlPaperA4
.FitToPagesWide = 1 'Fit All Columns to page
End With
xlApp.PrintCommunication = True
End Sub
已安装打印机驱动程序
答案 0 :(得分:0)
@Maxim试过你的代码,它正在运行。请记住,根据您的代码,您只需更改工作表“比较结果”的页面设置。 “数据输入”保持不变。
- 如果答案是正确的,请随意提升。