View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
smartin smartin is offline
external usenet poster
 
Posts: 915
Default About printing a document

FiluDlidu wrote:
Hi all,

I am looking around to see if anyone would have an idea on how a print job
could be cancelled if a certain cell within the print area has a certain
value or is an error. I would like something that would make something like
the following possible:

- I go to File\Print;
- Cell A1 value being 0 (or being an error, or containing no data), a
message box pops up to tell me the value of cell A1 is to be delt with before
the printing can occur;
- Printing is cancelled;
- I do whatever I have to do to make cell A1 value being valid;
- I go to File\Print;
- I get my usual dialog window, press OK and the document comes out of the
printer.

Any ideas?

Thanks for any thinking, even fruitless, anyone may put on this problem,

Feelu


Use the BeforePrint event in ThisWorkbook module. Something like this
(untested):

Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Range("A1").Value = 0 Then
Cancel = True
MsgBox "Error to be dealt with"
EndIf
End Sub

Note the code goes in the _Workbook_ module, not a sheet or standard module.