samilynn
Board Regular
- Joined
- Jun 24, 2003
- Messages
- 195
- Office Version
- 2016
- Platform
- Windows
This is my code to do print options so I don't have to set them every time, but it runs in all the tabs. I'd like it to run in only the active tab.
Thank you!
Sammy
Option Explicit
Public Sub Print_Portrait()
Dim ws As Worksheet
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each ws In ActiveWorkbook.Sheets
With ws
With .PageSetup
.Orientation = xlPortrait
.PrintGridlines = True
.CenterFooter = "Page &P of &N"
.PrintTitleRows = "$1:$1"
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0.41)
.BottomMargin = Application.InchesToPoints(0.41)
.HeaderMargin = Application.InchesToPoints(0.15)
.FooterMargin = Application.InchesToPoints(0.15)
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
End With
Next
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Thank you!
Sammy
Option Explicit
Public Sub Print_Portrait()
Dim ws As Worksheet
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each ws In ActiveWorkbook.Sheets
With ws
With .PageSetup
.Orientation = xlPortrait
.PrintGridlines = True
.CenterFooter = "Page &P of &N"
.PrintTitleRows = "$1:$1"
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0.41)
.BottomMargin = Application.InchesToPoints(0.41)
.HeaderMargin = Application.InchesToPoints(0.15)
.FooterMargin = Application.InchesToPoints(0.15)
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
End With
Next
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub