disable printing

  • Thread starter Thread starter Matthew Dyer
  • Start date Start date
M

Matthew Dyer

Is there any way to disable an excel file from being printed? I've run
into an issue where people are printing off sheets with sensetive
information on them and not being careful about throwing them away or
taking them off of the printer. They are printing off of a report that
I create daily, so I was hoping I could just disable printing
privelages on this file.
 
You could use a macro, but it's not foolproof.

Any user could disable macros or disable events and then print.

But if you want to try, this goes in the ThisWorkbook module.

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
MsgBox "Printing is disabled"
End Sub
 
You could use a macro, but it's not foolproof.

Any user could disable macros or disable events and then print.

But if you want to try, this goes in the ThisWorkbook module.

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Cancel = True
    MsgBox "Printing is disabled"
End Sub

This should probably go into the Programming part of excel but... do
you know how to create macro's in workbooks that are created by a
macro? does that question make any sense?
 
You can write code that writes code, but depending on the user's security
settings, it may not work for all your users.

If you want to look into doing this (I'd try not to), take a look at Chip
Pearson's site:
http://www.cpearson.com/excel/vbe.aspx

If the code never changes, I think an alternative approach would be to create a
template that contains all the code. Then instead of creating a workbook with
no code and then writing code to that workbook's project, I could create a new
workbook based on the template.

(A side benefit would be that I could protect that code in the template.)

Another option would be to separate the code completely from the workbook(s) and
put it into a separate addin. Then the users could open the addin when they
needed the macros.
 
Back
Top