Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 66
Default 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   Report Post  
Posted to microsoft.public.excel.misc
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.
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 964
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 66
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I have text on a template without it printing on a document? Melonie Excel Discussion (Misc queries) 3 October 23rd 07 09:36 PM
Not printing whole document syssupspe Excel Discussion (Misc queries) 2 April 9th 07 01:02 PM
Printing and copying an excel document midawson Excel Discussion (Misc queries) 1 January 27th 07 05:20 PM
document printing problems Maudib Excel Discussion (Misc queries) 0 January 11th 06 07:19 PM
Need help with printing Excel document jody mullis via OfficeKB.com New Users to Excel 6 June 27th 05 04:32 AM


All times are GMT +1. The time now is 12:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"