Thank you very muchVBA Password protect a Workbook after a certain date
I have been looking online for help with this code but haven't quite found what I am looking for and was hoping someone on here could help. I am looking to lock a workbook with a password after a certain date that will close entirely if the password is incorrect. Something to this effect...www.mrexcel.com
In addition to the comments about disabling macros in the above link, you might also want to password protect the code.
dear, footoo regardsVBA Password protect a Workbook after a certain date
I have been looking online for help with this code but haven't quite found what I am looking for and was hoping someone on here could help. I am looking to lock a workbook with a password after a certain date that will close entirely if the password is incorrect. Something to this effect...www.mrexcel.com
In addition to the comments about disabling macros in the above link, you might also want to password protect the code.
Private Sub Workbook_Open()
Dim exp_date As Date
Dim pword1$, pword2$, iResponse%
exp_date = Sheets("Hidden").[A1]
pword1 = "raji123"
If Date > exp_date Then
pword2 = Application.InputBox("Please enter your password.", "Login")
If pword2 <> pword1 Then ThisWorkbook.Close savechanges:=False
iResponse = MsgBox("Do you want to change the lock date?", vbOKCancel)
If iResponse = vbOK Then Call GetADate
End If
End Sub
Sub GetADate()
Dim TheString$
TheString = Application.InputBox("Enter a new lock date (d/m/yy)")
If IsDate(TheString) Then
Sheets("Hidden").[A1] = DateValue(TheString)
Else
MsgBox "Invalid date"
End If
End Sub