ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to prevent a specific worksheet from being printed ! (https://www.excelbanter.com/excel-programming/331086-how-prevent-specific-worksheet-being-printed.html)

RAFAAJ2000[_2_]

How to prevent a specific worksheet from being printed !
 
Hi all,

I have used the following code but this assumes the specific WorkSheet is
the active WorkSheet which is not necessarly always the case.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
MsgBox " Printing Cancelled!"
Cancel = True
End If
End Sub


Any ideas ?

Regards.



keepITcool

How to prevent a specific worksheet from being printed !
 
set the printarea for the sheet to an empty range?


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


RAFAAJ2000 wrote :

Hi all,

I have used the following code but this assumes the specific
WorkSheet is the active WorkSheet which is not necessarly always the
case.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
MsgBox " Printing Cancelled!"
Cancel = True
End If
End Sub


Any ideas ?

Regards.


JMB

How to prevent a specific worksheet from being printed !
 
I take it your question is how to test to see if a different worksheet (other
than the active sheet is being printed).

I believe when you print, the sheet being printed is the active sheet
(temporarily). Anytime you run a macro to print worksheets (and leave
screenupdating on) you'll see excel activating and looping through the
various worksheets.


"RAFAAJ2000" wrote:

Hi all,

I have used the following code but this assumes the specific WorkSheet is
the active WorkSheet which is not necessarly always the case.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
MsgBox " Printing Cancelled!"
Cancel = True
End If
End Sub


Any ideas ?

Regards.



William Benson

How to prevent a specific worksheet from being printed !
 
What if they say print entire workbook? Can you stop them from doing this
(since, obviously, this will include the active sheet which is undesirable
for printing?)
"JMB" wrote in message
...
I take it your question is how to test to see if a different worksheet
(other
than the active sheet is being printed).

I believe when you print, the sheet being printed is the active sheet
(temporarily). Anytime you run a macro to print worksheets (and leave
screenupdating on) you'll see excel activating and looping through the
various worksheets.


"RAFAAJ2000" wrote:

Hi all,

I have used the following code but this assumes the specific WorkSheet is
the active WorkSheet which is not necessarly always the case.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
MsgBox " Printing Cancelled!"
Cancel = True
End If
End Sub


Any ideas ?

Regards.





JMB

How to prevent a specific worksheet from being printed !
 
hmmm....then it does not appear to work. : )

definitely go with changing the printarea to a single empty cell (it looks
like the printer just spits out a blank page. i can't think of anything else
that would not be more trouble than it's worth. it would be nice to have an
after_print event handler.

thanks for pointing that out.

"William Benson" wrote:

What if they say print entire workbook? Can you stop them from doing this
(since, obviously, this will include the active sheet which is undesirable
for printing?)
"JMB" wrote in message
...
I take it your question is how to test to see if a different worksheet
(other
than the active sheet is being printed).

I believe when you print, the sheet being printed is the active sheet
(temporarily). Anytime you run a macro to print worksheets (and leave
screenupdating on) you'll see excel activating and looping through the
various worksheets.


"RAFAAJ2000" wrote:

Hi all,

I have used the following code but this assumes the specific WorkSheet is
the active WorkSheet which is not necessarly always the case.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
MsgBox " Printing Cancelled!"
Cancel = True
End If
End Sub


Any ideas ?

Regards.






RAFAAJ2000[_2_]

How to prevent a specific worksheet from being printed !
 
Clever trick KeepItcool :)

Thanks everyone else.

Jaafar.



"keepITcool" wrote:

set the printarea for the sheet to an empty range?


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


RAFAAJ2000 wrote :

Hi all,

I have used the following code but this assumes the specific
WorkSheet is the active WorkSheet which is not necessarly always the
case.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
MsgBox " Printing Cancelled!"
Cancel = True
End If
End Sub


Any ideas ?

Regards.



William Benson

How to prevent a specific worksheet from being printed !
 
I have never printed entire workbook in my life -- except maybe by accident
.... but for some goshdarn reason my boss's boss always did, and he nearly
took my head off when one of the pages was not formatted for it ...


"JMB" wrote in message
...
hmmm....then it does not appear to work. : )

definitely go with changing the printarea to a single empty cell (it looks
like the printer just spits out a blank page. i can't think of anything
else
that would not be more trouble than it's worth. it would be nice to have
an
after_print event handler.

thanks for pointing that out.

"William Benson" wrote:

What if they say print entire workbook? Can you stop them from doing this
(since, obviously, this will include the active sheet which is
undesirable
for printing?)
"JMB" wrote in message
...
I take it your question is how to test to see if a different worksheet
(other
than the active sheet is being printed).

I believe when you print, the sheet being printed is the active sheet
(temporarily). Anytime you run a macro to print worksheets (and leave
screenupdating on) you'll see excel activating and looping through the
various worksheets.


"RAFAAJ2000" wrote:

Hi all,

I have used the following code but this assumes the specific WorkSheet
is
the active WorkSheet which is not necessarly always the case.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
MsgBox " Printing Cancelled!"
Cancel = True
End If
End Sub


Any ideas ?

Regards.









All times are GMT +1. The time now is 07:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com