Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Prevent printing a sheet

I have a workbook with 10 worksheets. On two of the worksheets only I want
users to be able to view them but I don't want them printed. Is there a way
to do this so only these 2 worksheets won't print. Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Prevent printing a sheet

BeforePrint code will prevent if users have enabled macros.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim sht As Worksheet
For Each sht In ActiveWindow.SelectedSheets
If sht.Name = "Sheet1" Or sht.Name = "Sheet2" Then
MsgBox "you are not allowed to print " & sht.Name
Cancel = True
End If
Next
End Sub

Note: if both are selected you will get the message box twice.......once for
each sheet.


Gord Dibben MS Excel MVP

On Tue, 12 Jan 2010 11:09:01 -0800, LindaC
wrote:

I have a workbook with 10 worksheets. On two of the worksheets only I want
users to be able to view them but I don't want them printed. Is there a way
to do this so only these 2 worksheets won't print. Thanks


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Prevent printing a sheet

Thanks for the info. If I put this in the spreadsheet it works on all the
sheets, I only want to protect 2 of them from printing, thanks.

"Gord Dibben" wrote:

BeforePrint code will prevent if users have enabled macros.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim sht As Worksheet
For Each sht In ActiveWindow.SelectedSheets
If sht.Name = "Sheet1" Or sht.Name = "Sheet2" Then
MsgBox "you are not allowed to print " & sht.Name
Cancel = True
End If
Next
End Sub

Note: if both are selected you will get the message box twice.......once for
each sheet.


Gord Dibben MS Excel MVP

On Tue, 12 Jan 2010 11:09:01 -0800, LindaC
wrote:

I have a workbook with 10 worksheets. On two of the worksheets only I want
users to be able to view them but I don't want them printed. Is there a way
to do this so only these 2 worksheets won't print. Thanks


.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Prevent printing a sheet

How so?

The code is to be placed in Thisworkbook module.

If Sheet1 and Sheet2 are not incuded in the selected sheets there will be no
msgbox and printing will be carried out.

Requires users to CTRL + Click or SHIFT + Click to select sheets to print.

Then you select FilePrintActiveSheet(s)

Do not select "Entire workbook"


Gord


On Wed, 13 Jan 2010 08:36:01 -0800, LindaC
wrote:

Thanks for the info. If I put this in the spreadsheet it works on all the
sheets, I only want to protect 2 of them from printing, thanks.

"Gord Dibben" wrote:

BeforePrint code will prevent if users have enabled macros.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim sht As Worksheet
For Each sht In ActiveWindow.SelectedSheets
If sht.Name = "Sheet1" Or sht.Name = "Sheet2" Then
MsgBox "you are not allowed to print " & sht.Name
Cancel = True
End If
Next
End Sub

Note: if both are selected you will get the message box twice.......once for
each sheet.


Gord Dibben MS Excel MVP

On Tue, 12 Jan 2010 11:09:01 -0800, LindaC
wrote:

I have a workbook with 10 worksheets. On two of the worksheets only I want
users to be able to view them but I don't want them printed. Is there a way
to do this so only these 2 worksheets won't print. 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 Steven Chan Excel Discussion (Misc queries) 4 September 20th 09 03:10 AM
Prevent color printing jemarin71 Excel Discussion (Misc queries) 2 September 11th 06 08:55 PM
prevent empty rows from printing dill_weed Excel Worksheet Functions 11 August 20th 06 05:33 PM
Prevent Printing of Specific Cells Ken Mitchell Excel Discussion (Misc queries) 5 May 16th 06 07:26 PM
Prevent header from printing on 1st page? Bubba B Excel Discussion (Misc queries) 1 March 16th 06 07:09 PM


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