How can I prevent others printing a worksheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Guest
I want to allow others to view a workbook as read only (which is not a problem) but I can't work out how to prevent them from printing it.

I still need to print it myself.

Many thanks for your help.

Bazil
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Using VBA you can do this. On the worksheet object you could put this code in :

<pre>
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
End Sub

</pre>

This is not a perfect solution, but it does stop them from printing.
 
Upvote 0
This is a fairly "simple" solution which doesn't use macros, but it works fine.

Put your cursor in cell A1 - make sure that row 1 is empty as you will be hiding it later. Goto File, Print Area, Set print Area. Select row 1 and hide it, then protect the sheet. If someone tries to print it will print a blank page as the print area does not contain any info. You hide row A to prevent anyone moving the page breaks (which you can do even if the sheet has been protected), but you cannot unhide a row if the sheet has been protected.
 
Upvote 0
Try this code in the WorkBook Module.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
'Input box to verify password

Dim myPassword As String

myPassword = InputBox(prompt:="Please enter the password to proceed:", _
Title:="Password is required to print this file.")

If myPassword <> "Password" Then
MsgBox prompt:="Click OK to return to Report.", _
Title:="Cancelled -- correct password not entered", _
Buttons:=16
Cancel = True

Else
End If
End Sub

Change "Password" as desired
 
Upvote 0

Forum statistics

Threads
1,223,355
Messages
6,171,608
Members
452,411
Latest member
sprichwort

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