How can I prevent others printing a worksheet

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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
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,213,561
Messages
6,114,317
Members
448,564
Latest member
ED38

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