2

我需要输入工作表名称吗?我需要在具有相似工作表但选项卡名称不同的多个工作簿中使用此宏。

Sub pageSetup()
ActiveSheet.pageSetup
.Orientation = xlLandscape
.PaperSize = xlPaperLegal
.FitToPagesWide = 1
.FitToPagesTall = 1
.LeftMargin = Application.InchesToPoints(1#)

End Sub
4

1 回答 1

4

由于蒂姆没有声称他的答案,您可以使用以下两个选项之一

  • 格式化ActiveSheet
  • WorkSheets全部格式化ActiveWorkBook

活动表

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
于 2012-12-12T03:11:37.713 回答