Excel Security

A

apache007

Through data protection, we can lock sheet and workbook.

Is there a way to prevent a user or set a password for printing excel???
 
D

Dave Peterson

Maybe...

You could turn off all printing and then provide a macro that would print under
the conditions you want.

But this would all depend on macros and macros can be disabled. So it would
only be effective if macros are enabled.

This goes behind the ThisWorkbook module:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
MsgBox "Please use the macro/button/whatever to print"
Cancel = True
End Sub


And this goes in a general module (and assigned to a button from the Forms
toolbar???):


Option Explicit
Sub DoMyPrint()

Dim pwd As String
pwd = InputBox(Prompt:="Enter a Password")

If pwd <> "TopSecret PassWord Here" Then
MsgBox "no printing allowed"
Exit Sub
End If

Application.EnableEvents = False
Worksheets("sheet1").PrintOut preview:=True
Application.EnableEvents = True

End Sub
 
D

Dave Peterson

Maybe...

You could turn off all printing and then provide a macro that would print under
the conditions you want.

But this would all depend on macros and macros can be disabled. So it would
only be effective if macros are enabled.

This goes behind the ThisWorkbook module:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
MsgBox "Please use the macro/button/whatever to print"
Cancel = True
End Sub


And this goes in a general module (and assigned to a button from the Forms
toolbar???):


Option Explicit
Sub DoMyPrint()

Dim pwd As String
pwd = InputBox(Prompt:="Enter a Password")

If pwd <> "TopSecret PassWord Here" Then
MsgBox "no printing allowed"
Exit Sub
End If

Application.EnableEvents = False
Worksheets("sheet1").PrintOut preview:=True
Application.EnableEvents = True

End Sub
 
A

apache007

Wow, another thing to learn.

I wish in the future excel feature can be added with print protection.

Thanks Dave.
 
A

apache007

Wow, another thing to learn.

I wish in the future excel feature can be added with print protection.

Thanks Dave.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top