View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JRK JRK is offline
external usenet poster
 
Posts: 8
Default Prevent Printing in Print Preview?



"Neptune Dinosaur" wrote:

There is a way to do this in XL2003 which may exist in 97 also. It actually
prevents normal printing entirely, but you allow the user to print by
providing a command button. The command button has code that gives the
appropriate print commands(as fits your purpose). You use the
Workbook_BeforePrint event to inhibit printing (you inhibit with the command
"Cancel = True") unless a boolean variable is set to True. You set this
boolean to True at the top of the code that runs when the command button is
pressed, and back to False at the end of it.

In the Workbook_BeforePrint event code, you set Cancel to True only if the
boolean variable is False, i.e. if the user accesses any Print-related
function (including Preview) by means other than your button, Cancel will be
True and the Print will not go ahead. I've used this several times in XL
2003 and it works a treat.
--
Time is just the thing that keeps everything from happening all at once


"JRK" wrote:

Is there a way to prevent a user from printing in Print Preview? I don't
think I can disable the button using VBA, but perhaps someone knows of a way
to prevent the print command using VBA. It would be great if procedure works
for Excel 97 + Thank you.


Thank you, Neptune. I'm a bit of a novice, however. Can you please give me
the procedure and where to post. I currently use a sub to activate Print
Preview

With Sheets("my sheet")
.Visible = True
.PrintOut preview:=True
.Visible = False
End With

This works well. Now if you would just be so kind as to tell me how and
where I can stop the print command. Thank you, again.