Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default Prevent printing of certain sheets

"GS" wrote in message
Thanks Garry, but the _BeforePrint event executes in full before printing,
so if I unhide the sheets, the sheets will print.


You're not getting it!...

'hide not to print sheets
'call procedure to print
'_BeforePrint is NOT where to hide not to print sheets
'unhide not to print sheets

Your reply suggests you are doing everything in one procedure. BAD
IDEA!(IMO) but still doable if you hide/print/unhide so _BeforePrint isn't
even in the picture!


Hi Garry,

Hi Peter...

The OP's question is a little ambiguous. It could be interpreted as you did
if the objective were in his own routine to exclude some sheet(s) from being
printed. Indeed something along the lines you suggest would be good, and as
you say the BeforePrint doesn't come into it.

However probably no need to hide any sheets, in the print procedure simply
Worksheets(ArrayOfSheetsToPrint).PrintOut
(the array could be populated in current sheet order if/as appropriate)


This is the way I do it, but felt it's a bit over complicated to introduce
here.

vShtsToPrint = Split(sShtsToPrint, ",")
Worksheets(vShtsToPrint).PrintOut

I interpreted the problem being about if the user clicks Print from the
Ribbon or does Ctrl-P. BeforePrint will fire but then no control over what
the user might attempt to print. Maybe the user might be allowed to print
anything except specified sheets. For that scenario hiding sheets in the
BeforePrint and re-showing in an OnTime would be one way to handle it. Though
would need rather more that I showed in the way of error handling and to
ensure the sheets get re-shown in some other way if the OnTime failed for any
reason.


Yes, I got the same suspicion as to what the OP was doing. The OnTime approach
is a good idea in the _BeforePrint event, but I still feel it shouldn't be done
that way. Using _BeforePrint for evaluating conditionals related to the
printing itself wherein Cancel is set true accordingly is more appropriate.

IMO, if the project is that complex then it ought to have its own dedicated
procedures designed specifically for its tasks!

Of course nothing to stop the user taking a screenshot and printing it!

Peter T


--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
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
prevent certain cells from printing Wally Excel Discussion (Misc queries) 2 May 15th 10 10:39 PM
Prevent printing a sheet LindaC Excel Discussion (Misc queries) 3 January 13th 10 06:32 PM
Prevent Printing Steven Chan Excel Discussion (Misc queries) 4 September 20th 09 03:10 AM
Prevent Printing Pats Excel Programming 1 June 16th 09 06:59 AM
Prevent printing of some sheets and not others in a single doc? kblake Excel Programming 2 September 23rd 05 11:38 AM


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

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

About Us

"It's about Microsoft Excel"