2007: How to disable printing when a specific cell is blank

A

Aaron

Hello,

I am trying to disable all printing when a specific cell on a worksheet is
blank. Meaning there is no way a user can print anything from the worksheet
until the cell has been filled.
Any code samples or examples would be both appreciated and helpful. This
example needs to work for Excel 2007, working for any other versions is a
bonus.

Thanks for the help in advance,
Aaron
 
T

Trevor Williams

Hi Aaron

add this to your Workbook module

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Range("A1") = "" Then
MsgBox ("STOP")
Cancel = True
End If
End Sub

HTH
Trevor Williams
 
A

Aaron

However, I have one more question and Im not sure if this should be another
post or not... Would it be possible to do stop printing if the cell is blank
but still be able to view the print preview?

Thanks,
Aaron
 
T

Trevor Williams

Hmmm, that's a good question. Give me 5 mins and I'll try and suss it out.
 
T

Trevor Williams

Sorry Aaron - probably best to post it as a new question as it's not a 5 min
job (for me at least).

Should be possible though as just need to catch what event triggered the
beforeprint module. (printout or printpreview)

Trevor
 
A

Aaron

Ok, still I really appreciate the time, help and effort you have offered.
Thanks for that. I have reposted my question with the added print preview
requirement.

Thanks again!,
Aaron
 
R

rebecca puck

Aaron and Trevor,

This is exactly what I am looking to do, however when looking at Aaron's
directions I am not sure where to input this information. I am also
using excel 2007. Can you point me in the right direction of where I
need to insert this information?

Thank you,
Rebecca
 

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