ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Prevent Printing (https://www.excelbanter.com/excel-programming/429909-prevent-printing.html)

PATS

Prevent Printing
 
My code below is designed to lockdown my workbook if the user selects Read
Only. What I am wondering, is there any way to also prevent them from
printing the document?


Private Sub CommandButton1_Click()

On Error GoTo Termination

If Me.OptionButton1.Value = True Then
myLocked = True
Unload UserFormAccess
Call Protection.protect_all_sheets
ElseIf Me.OptionButton2.Value = True Then
myLocked = False
Unload UserFormAccess
UserFormPassword.Show
End If

GoTo LastLine

Termination:

LastLine:

End Sub

FSt1

Prevent Printing
 
hi
put this in a thisworkbook module...
Private Sub Workbook_BeforePrint(Cancel As Boolean)

MsgBox "you can't print this!"
Cancel = True

End Sub

adjust message to suit your tastes/needs.
or you might add an if then else statement to allow printing under certain
conditions. your call.
regards
FSt1

"Pats" wrote:

My code below is designed to lockdown my workbook if the user selects Read
Only. What I am wondering, is there any way to also prevent them from
printing the document?


Private Sub CommandButton1_Click()

On Error GoTo Termination

If Me.OptionButton1.Value = True Then
myLocked = True
Unload UserFormAccess
Call Protection.protect_all_sheets
ElseIf Me.OptionButton2.Value = True Then
myLocked = False
Unload UserFormAccess
UserFormPassword.Show
End If

GoTo LastLine

Termination:

LastLine:

End Sub



All times are GMT +1. The time now is 11:36 AM.

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