ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Excel Security (https://www.excelbanter.com/excel-discussion-misc-queries/231362-excel-security.html)

apache007

Excel Security
 
Through data protection, we can lock sheet and workbook.

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

Dave Peterson

Excel Security
 
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


apache007 wrote:

Through data protection, we can lock sheet and workbook.

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


--

Dave Peterson

Dave Peterson

Excel Security
 
ps.

If you're new to macros:

Debra Dalgleish has some notes how to implement macros he
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

apache007 wrote:

Through data protection, we can lock sheet and workbook.

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


--

Dave Peterson

apache007

Excel Security
 
Wow, another thing to learn.

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

Thanks Dave.



"Dave Peterson" wrote:

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


apache007 wrote:

Through data protection, we can lock sheet and workbook.

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


--

Dave Peterson



All times are GMT +1. The time now is 12:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com