Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Cancel Print?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rookie 1st class - 30 Jan 2006 22:32 GMT
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 - 30 Jan 2006 23:14 GMT
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 - 31 Jan 2006 22:52 GMT
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.

> To get the print to be canceled, you need:
>
[quoted text clipped - 7 lines]
>     'Display MsgBox and any other things that need to be done
> Endif
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.