ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cancel Print? (https://www.excelbanter.com/excel-programming/351868-cancel-print.html)

Rookie 1st class

Cancel Print?
 
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


Bill Schanks

Cancel Print?
 
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


Rookie 1st class

Cancel Print?
 
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.

"Bill Schanks" wrote:

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




All times are GMT +1. The time now is 07:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com