View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Cancel Printing Except Q

You could add some code to disable events (including the _beforeprint event) in
your code that gets/validates the password.

dim myPwd as string
'some validation here
if mypwd = "oktoprint" then
application.enableevents = false
worksheets("whatever").printout
application.enableevents = true
end if

And the _BeforePrint routine won't even run.

Sean wrote:

I have the following code which prevents priniting of a document. Would
it be possible to allow printing if the correct password was entered
within a userform? So on clicking the Print Icon an input box which
required the password would appear, if it is correct, document prints,
if it isn't document doesn't. If so how would I do it?

Thanks

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
End Sub


--

Dave Peterson