worksheet before_print event...


Posted by Jojo on January 04, 2002 5:33 AM

is this possible..i like to make thing possible..
hope you guys can help me..

let say i use sheet1..before user can print anything ..
a macro will run ( worksheet before_print event.)
and write to all the cells that are used..(print something
like "trial" to all cells...after that input box
will prompt the user to keyin the right password..if the
password is correct..another macro will run
and delete all the "trial " words in all the cell..if the
passwword is wrong . "trial" words will remain and the sheet
will be print with "trial" all over the sheet..thanks and
hope someone will help me in achieved this..happy new
year to all excel experts here..regards

Posted by Ivan F Moala on January 04, 2002 1:39 PM

Yes
Something like this may help;

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim Pwd As String

If ActiveSheet.Name = "Sheet1" Then
Pwd = InputBox("Enter password before printing", "Password Required")
If Pwd <> "test" Then
Range("A1:G200") = "Trial"
Cancel = True
Else
Range("A1:G200") = ""
End If
End If

End Sub

Ivan



Posted by Jojo on January 04, 2002 6:18 PM

Thanks Ivan..but i think this method is not relevant..coz if the
user supplied the wrong password, all the data and
the formula will be deleted..so i have come with
1 solution..how to make user to key in a password
in order to print or to save the workbook..if the password
is wrong...the workbook wil close automatically and all
works will be not saved..thanks