Is it possible?


Posted by qkp on July 31, 2001 7:56 PM

Is it possible to insert a Master Password into a Workbook that will need to be entered every -lets say 50th time the workbook is opened? This would be on top of the current password used every time it is opened.
Thanks for any help!



Posted by steve w on July 31, 2001 8:58 PM

Here try this

What you need to do is paste this into the workbook module. The way it keeps track of the number of opens is a cell in a worksheet, everytime its opened it adds one to that number.
The cell is currently sheet1 A1 change it to whatever you want. Ihe password is set to
yourpassword
change to whatever you want.
Its set to 50 opens and at 50 if the passwords incorrect the workbook will close automatically.
Hope this helps let me now if you need more help

steve w

Private Sub Workbook_Open()

a = Sheet1.Range("a1") ' The cell that keeps track of opens
a = a + 1
Sheet1.Range("a1") = a
If a >= 50 Then 'Number of times workbook is opened
Msg = "Enter Password"
ValidEntry = False

UserEntry = InputBox(Msg)

If UserEntry = "yourpassword" Then 'the yourpassword is password
Sheet1.Range("a1") = ""
ValidEntry = True
Else
MsgBox "Your password was incorrect."
Application.DisplayAlerts = False
ActiveWorkbook.Close 'closes worbook if false
Exit Sub

End If

End If
End Sub