About printing a document

F

FiluDlidu

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
 
E

Elkar

I've got a Timesheet that I created that does this very thing. It checks
several areas to make sure the employee filled it out correctly before
allowing them to print. Try this VB Code in the Workbook - BeforePrint
section:

Private Sub Workbook_BeforePrint(Cancel As Boolean)

Dim wks As Worksheet
Set wks = Worksheets("Your Worksheet")

If wks.Range("A1") = 0 Then
MsgBox ("Printing canceled due to the following error: Cell A1 may not
equal 0.")
Cancel = True
End If

End Sub

HTH
Elkar
 
F

FiluDlidu

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

Now I understand why this didn't work for me!

Thank you very much for your help.

Feelu
 

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