Disabling Printing of Specific Worksheet

Krazy Ivan

New Member
Joined
Feb 29, 2004
Messages
2
Here is my problem. I have a workbook that people print using the standard print functions through Excel. However, I need it to print and reset the worksheet, without changing the formatting or anything.

Now, I have disabled the print button in the command bars and in the File menu. Is there any way to disable printing via shortcut (Ctrl + P)? This is the only whole I can see that would allow them to print in any way other than the way I want them to print. Any help is appreciated. Thanks.

- Daniel
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi Daniel,

Welcome to the forum :biggrin:

Rather than mess with people's menus (which they won't appreciate if they are not restored properly for some reason :wink: ) how about just using the BeforePrint event?

Consider the code below:

In the ThisWorkbook object
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    If bOKtoPrint = False Then Cancel = True
End Sub
and in a general module:
Code:
Public bOKtoPrint As Boolean

Sub TestPrint()
    bOKtoPrint = True
    'set public variable to true before printing
    '
    'do your printing
    '
    bOKtoPrint = False
    'set to false to prevent any printing other than through this routine
End Sub
What this does is use the BeforePrint event to determine whether the print is allowed or not. If its from your own print routine then the print proceeds, if not then it is cancelled.

HTH

PS: You could shorten the BeforePrint code to "Cancel = Not bOKtoPrint" but I figured it was easier to follow the longer version!
 
Upvote 0
Thanks :)

The thing is that I need it to be able to print most of the other worksheets in this workbook through regular printing methods (allowable through hitting the print button or print option through the File menu). However, there are two sheets they print this way that I want to make impossible, because in the print method I set up, it removes borders and values, which is a must, otherwise, when it prints, it prints nearly 8 pages, as opposed to the 2 or 3 I need it to print.

So, I figured the easiest way to do this is to make it impossible to access normal print methods. I got the print button on the Toolbar and the Print option on the File menu to be disabled, however, the shortcut (Ctrl + P) is still allowing it to print. I need to stop this. Is there any way to do so?

- Daniel
 
Upvote 0

Forum statistics

Threads
1,214,608
Messages
6,120,500
Members
448,968
Latest member
screechyboy79

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top