Forum Discussion
Marc_Mes
Jan 30, 2019Copper Contributor
excel protect
Hello, I like to protect an excel worksheet for opening with a password, but it have to work just after a while. So, i give a worksheet to some one, and he or she can use it for, example, a month. A...
Wyn Hopkins
Jan 30, 2019MVP
Something like this
Private Sub Workbook_Open()
Dim ExpiryDate As String
Dim pwd As String
pwd = "ABC"
ExpiryDate = "28/01/2019"
If Date > ExpiryDate Then
MsgBox "Password has expired", vbCritical, "Expired Password!"
If InputBox("Enter Password", "", "") <> pwd Then
'enter a close or repeat password routine here
MsgBox "Close"
Exit Sub
End If
End If
End SubMarc_Mes
Jan 30, 2019Copper Contributor
I think i need more help, because het won't work. I probebly make a mistake.
Marc.
Netherlands
- Wyn HopkinsJan 30, 2019MVPHi, have you written much vba before?
Are you getting an error message?