2

シート名を入れる必要がありますか?このマクロは、同じようなワークシートを持つ複数のワークブックで使用する必要がありますが、タブ名が異なります。

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

End Sub
4

1 に答える 1

4

As Tim has not claimed his answer, you could use either of the following two options to either

  • format the ActiveSheet
  • format all WorkSheets in the ActiveWorkBook

ActiveSheet

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

All Sheets

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 に答える