Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim wsSheet As Worksheet
Dim rng As Range, ar As Range
Dim lngZ As Long
Dim ans as Variant
' MsgBox "In BeforePrint"
For Each wsSheet In ActiveWindow.SelectedSheets
Select Case LCase(wsSheet.Name)
Case "scorecard"
lngZ = 95
With wsSheet
Set rng = .Range("B1:BA45")
End With
Case "customer", "financial", "learning", "process"
lngZ = 90
With wsSheet
Set rng = .Range("B1:BA32,B33:BA64,B65:BA96")
End With
Case Else
With wsSheet.PageSetup
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
Exit Sub
End Select
vVal = wsSheet.PageSetup.Zoom
With wsSheet.PageSetup
.Zoom = lngZ
End With
Cancel = True
On Error GoTo ErrHandler
Application.EnableEvents = False
For Each ar In rng.Areas
ans = _
MsgBox( "Zoom: " & wsSheet.PageSetup.Zoom _
& " - " & ar.Address(external:=True) & _
vbNewLine & vbNewline & "Print this out?", vbYesNo)
if ans = vbYes then
ar.PrintOut
end if
Next
Next
ErrHandler:
Application.EnableEvents = True
End Sub
--
Regards,
Tom Ogilvy
Phil Hageman said:
Tom, I removed the line and the code works! Thank you very much.
When the message box comes up asking for OK to print a particular range,
can we add a "no" option to not print that range? Sometimes the second or
third range may be empty of data.