Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Prevent printing of some sheets and not others in a single doc?

I need to disable the Print command in 11 out of 15 sheets (tabs) in a single
document. I have the VB script for disabling printing for the entire document
but I would like to know if it is possible the disable printing on selected
sheets.
Thanks...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Prevent printing of some sheets and not others in a single doc?

I don't think you can.

The user can always choose "whole document" or group sheets before printing and
you won't know what sheets are being printed.

If the user were always just printing the activesheet, you could stop them:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)

Dim mySheetNames As Variant

mySheetNames = Array("sheet1", "sheet2", "sheet3")

If IsNumeric(Application.Match(ActiveSheet.Name, mySheetNames, 0)) Then
Cancel = True
MsgBox "Nope!"
End If

End Sub

Just keep adding all the sheets you don't want to print to that array.

This goes under the ThisWorkbook module.

But it sure ain't perfect--disabling macros/events would allow printing, too!

kblake wrote:

I need to disable the Print command in 11 out of 15 sheets (tabs) in a single
document. I have the VB script for disabling printing for the entire document
but I would like to know if it is possible the disable printing on selected
sheets.
Thanks...


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Prevent printing of some sheets and not others in a single doc?

kblake,
How about:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim WS As Worksheet

For Each WS In ActiveWindow.SelectedSheets
If WS.Name = "Banned Sheet" Then
MsgBox "Printing of " & WS.Name & " is not allowed."
Cancel = True
Exit Sub
End If
Next

End Sub

Or use Application level events for the same.
However this also PrintPreview, which maybe a problem.

NickHK

"kblake" wrote in message
...
I need to disable the Print command in 11 out of 15 sheets (tabs) in a

single
document. I have the VB script for disabling printing for the entire

document
but I would like to know if it is possible the disable printing on

selected
sheets.
Thanks...



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 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
Printing single pages from multiple worksheets in a single print job [email protected] Excel Discussion (Misc queries) 2 April 27th 07 06:11 PM
Prevent color printing jemarin71 Excel Discussion (Misc queries) 2 September 11th 06 08:55 PM
when printing multiple sheets, first prints single side rest doub. Loz Setting up and Configuration of Excel 0 May 18th 06 04:42 AM


All times are GMT +1. The time now is 09:23 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"