Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
About printing a document
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 |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
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. |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
About printing a document
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 "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 |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
About printing a document
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can I have text on a template without it printing on a document? | Excel Discussion (Misc queries) | |||
Not printing whole document | Excel Discussion (Misc queries) | |||
Printing and copying an excel document | Excel Discussion (Misc queries) | |||
document printing problems | Excel Discussion (Misc queries) | |||
Need help with printing Excel document | New Users to Excel |