我需要输入工作表名称吗?我需要在具有类似工作表的多个工作簿中使用此宏,但选项卡名称不同。
Sub pageSetup()
ActiveSheet.pageSetup
.Orientation = xlLandscape
.PaperSize = xlPaperLegal
.FitToPagesWide = 1
.FitToPagesTall = 1
.LeftMargin = Application.InchesToPoints(1#)
End Sub
答案 0 :(得分:4)
由于Tim没有声明他的回答,你可以使用以下两个选项中的任何一个
ActiveSheet
WorkSheets
ActiveWorkBook
<强> ActiveSheet 强>
Sub TimWilliamsPoints()
With ActiveSheet.pageSetup
.Orientation = xlLandscape
.PaperSize = xlPaperLegal
.FitToPagesWide = 1
.FitToPagesTall = 1
.LeftMargin = Application.InchesToPoints(1#)
End With
End Sub
所有表格
Sub TimWilliamsPoints2()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
With ws.pageSetup
.Orientation = xlLandscape
.PaperSize = xlPaperLegal
.FitToPagesWide = 1
.FitToPagesTall = 1
.LeftMargin = Application.InchesToPoints(1#)
End With
Next ws
End Sub