Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JRK JRK is offline
external usenet poster
 
Posts: 8
Default Prevent Printing in Print Preview?

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Prevent Printing in Print Preview?

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.

  #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.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Prevent Printing in Print Preview?

*Go to the Visual Basic Editor (from Excel, go Tools/Macro/Visual Basic
Editor)
*In the VB Editor, make sure the Project Explorer window is visible
(View/Project Explorer - there's also a button up in the toolbar for this,
which you will find easily enough if you nose around for it)
*In the Project Explorer, expand the "tree" for the VBA project that you
want to work on - it will have the name of the relevant Excel file in brackets
*DoubleClick on the "This Workbook" object within that tree
* There will be 2 dropdown boxes up near the top of the screen. Make sure
the left hand one says "Workbook" rather than "General"
* Scroll around in the right hand dropdown for "BeforePrint". When you
select it, the editor will place the"shell" of a Sub in the code window for
you. Whack your code in there and off you go. Note that the Sub comes
pre-loaded with the parameter "Cancel as Boolean" - If you go "Cancel =
True", the Print will not go ahead. Obviously you can play around with that
and make it conditional, as I described before.
* Hope this is all OK in XL97 !!!!!!

It's worthwhile having a good look at all of the other events that you can
harness in a Workbook and on individual Sheets. These are things that can
help turn little macro-driven Excel files into real interactive
mini-applications suitable for users who don't have much IT savvy (welcome to
my world ...)

PS: My name is not really Neptune, but time really is just the thing that
keeps everything from happening all at once
--
Time is just the thing that keeps everything from happening all at once


"JRK" wrote:



"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.

  #5   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:

*Go to the Visual Basic Editor (from Excel, go Tools/Macro/Visual Basic
Editor)
*In the VB Editor, make sure the Project Explorer window is visible
(View/Project Explorer - there's also a button up in the toolbar for this,
which you will find easily enough if you nose around for it)
*In the Project Explorer, expand the "tree" for the VBA project that you
want to work on - it will have the name of the relevant Excel file in brackets
*DoubleClick on the "This Workbook" object within that tree
* There will be 2 dropdown boxes up near the top of the screen. Make sure
the left hand one says "Workbook" rather than "General"
* Scroll around in the right hand dropdown for "BeforePrint". When you
select it, the editor will place the"shell" of a Sub in the code window for
you. Whack your code in there and off you go. Note that the Sub comes
pre-loaded with the parameter "Cancel as Boolean" - If you go "Cancel =
True", the Print will not go ahead. Obviously you can play around with that
and make it conditional, as I described before.
* Hope this is all OK in XL97 !!!!!!

It's worthwhile having a good look at all of the other events that you can
harness in a Workbook and on individual Sheets. These are things that can
help turn little macro-driven Excel files into real interactive
mini-applications suitable for users who don't have much IT savvy (welcome to
my world ...)

PS: My name is not really Neptune, but time really is just the thing that
keeps everything from happening all at once
--
Time is just the thing that keeps everything from happening all at once


"JRK" wrote:



"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.


Thank you for that information. I'll see if I can make it work.
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
Pictures and/or Graphs in Print Preview not Printing in Excel and Catnik Excel Discussion (Misc queries) 1 September 29th 09 07:51 PM
Print Preview does not allow printing F W Green Excel Discussion (Misc queries) 1 April 29th 08 02:32 PM
how do I fix printing-able to see as preview, but print out blank Zum Excel Discussion (Misc queries) 0 November 5th 07 02:46 PM
Chart Resizes After Printing or Print-Preview CA Excel Discussion (Misc queries) 3 June 12th 07 08:21 PM
Checkbox Moves on Printing/Print Preview Peter Bernadyne Excel Discussion (Misc queries) 1 April 27th 06 12:50 AM


All times are GMT +1. The time now is 08:06 AM.

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"