Cancel Print?

G

Guest

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim MyResponse As WorksheetFunction
If Range("F31") = "" Then
Range("F31").Select
Response = MsgBox(Prompt:="Did you leave this blank
intentionally?", Buttons:=vbYesNoCancel + vbDefaultButton1, Title:="; BLANK?;
")
ElseIf Range("D32") = "" Then
Range("D32").Select
Response = MsgBox(Prompt:="Did you leave this blank
intentionally?", Buttons:=vbYesNoCancel + vbDefaultButton1, Title:="; BLANK?;
")
ElseIf Range("C33") = "" Then
Range("C33").Select
Response = MsgBox(Prompt:="Did you leave this blank
intentionally?", Buttons:=vbYesNoCancel + vbDefaultButton1, Title:="; BLANK?;
")
If Response = vbNo Then
Exit Sub
End If
End If
End Sub

2.5 questions:
1. vbYes works fine... I want to cancel print job (return to edit) if
response is vbNo.
2. Instead of 3 message boxes (one for each range checked), can I use one
message box? If Yes how?
Thanks
Lou
 
B

Bill Schanks

To get the print to be canceled, you need:

Cancel = True

In the code.

As far as 1 Message box, you would do something like:

If Range("F31") = "" or Range("D32") = "" or Range("C33") = "" Then
'Display MsgBox and any other things that need to be done
Endif
 
G

Guest

I swear on a stack of UCMJs I tried that minus the "Cancel = True" and got an
error if all three ranges had values; it is working now...
Thanks Bill
Lou
I am using Excel 97 upgraded from Excel 95 and program help is spotty at
best. I keep hoping the computer Gods will smile and I'll get a new system
but the other things more important Gods keep slipping my priority. Any
suggested sources of assistance would be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top