Associate
- Joined
- 25 Aug 2005
- Posts
- 717
- Location
- Derbyshire
I am trying to restrict printing on an excel sheet I have. I have managed to do this by using VAB and the following code
Now, I want to be able to allow users to print if they enter the right value into a textbox in a userform and then press a "print" button. This is what I'm having problems with.
It will obviously have to involve an if statement along the line of:
But I'm having problems with the correct VBA terminology for this.
Any help would be great, thanks
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
MsgBox ("If you require a hard copy of this sheet, please inform xxxxxxxx")
End Sub
Now, I want to be able to allow users to print if they enter the right value into a textbox in a userform and then press a "print" button. This is what I'm having problems with.
It will obviously have to involve an if statement along the line of:
Code:
If textbox1 = "value" then
activeworksheet.print
Else cancel print
But I'm having problems with the correct VBA terminology for this.
Any help would be great, thanks