Archive of Mr Excel Message Board

Back to Printing in Excel archive index
Back to archive home

How do I stop a worksheet from being printed
Posted by Sean on April 06, 2000 12:59 PM
I am quite new to excel but I would like to prevent anybody from taking a Hardcopy of a particular worksheet.
I have put the following code into the before print workbook event and it displays the message OK but then allows printing can anyone help please.
If Activesheet.Name ="Test" Then
MsgBox "this sheet cannot be printed",VbOKOnly,"Non Print Test",0, Cancel = True
end if
I even tried putting in an Application.quit statement after the end if to stop it getting to the print dialog but that did not work.
Am I using this routine correctly? Or is it not possible to prevent printing.
Any Help would be gratefully received
Thanks in advance

Re: How do I stop a worksheet from being printed
Posted by Ivan Moala on April 06, 2000 2:32 PM
Slight change in the above gets it going
If Activesheet.Name ="Test" Then
MsgBox "this sheet cannot be printed",VbOKOnly,"Non Print Test":Cancel = True
end if
Ivan

Thanks
Posted by Sean on April 07, 2000 5:19 AM
Thank you very much for your help.
The code works just fine now
Thanks
Sean

This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our
online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.