Message before print for specified worksheets

  • Thread starter Thread starter inta251 via OfficeKB.com
  • Start date Start date
I

inta251 via OfficeKB.com

On OfficeKB i found code

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Msg = "Warning message"
Title = "Warning TITLE"
Response = MsgBox(Msg, vbYesNo + vbQuestion, Title)
If Response = vbNo Then
Cancel = True
Exit Sub
End If
End Sub

This code for all workbook.
Need code for specified worksheets.
In my situation for now i have two worksheets 'trips' and 'statistic'
in the future may be more.
Where page setup > paper size: Legal (8 1/2 x 14 in).
Messege will be: "Before print please insert to your printer paper size:
Legal (8 1/2 x 14 in)."

Thanks in advance.
Sincerely, Igor (inta251)
 
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet
Select Case .Name
Case "trips", "statistic":
Msg = "Before print please insert to your printer paper
size:" & _
vbNewLine & "Legal (8 1/2 x 14 in)"
Title = "Warning TITLE"
Response = MsgBox(Msg, vbYesNo + vbQuestion, Title)
If Response = vbNo Then
Cancel = True
Exit Sub
End If
End Select
End With
End Sub


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Thanks for respond.
Code working perfect.
THANKS again.
Sincerely, Igor (inta251)
 
Back
Top