Assign Expiry date

raji123

New Member
Joined
Jun 17, 2022
Messages
11
Office Version
  1. 2013
Platform
  1. Windows
Can somebody help me for subject topic, How can we add expiry date (Time-Lock) to a Excel workbook so that after that date Workbook gets lock and required password to re-validate/Unlock ???

Regards,
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

In addition to the comments about disabling macros in the above link, you might also want to password protect the code.
 
Upvote 0

In addition to the comments about disabling macros in the above link, you might also want to password protect the code.
Thank you very much
 
Upvote 0

In addition to the comments about disabling macros in the above link, you might also want to password protect the code.
dear, footoo regards
can you help one more thing,
how can I use the above code for every week ?
"like, every friday mid night it will be locked and when i want to change lock date
then I can input lock date like password input"
is this possible??

thanks
 
Upvote 0
Private Sub Workbook_Open()
Dim exp_date As Date
Dim pword1 As String, pword2 As String

exp_date = "2022/07/01"
pword1 = "raji123"

If Date > exp_date Then
pword2 = Application.InputBox("Please enter your password.", "Login")
If pword2 = pword1 Then
GoTo Proceed
Else
ThisWorkbook.Close savechanges:=False
End If
End If
Proceed:
End Sub
 
Upvote 0
Here's one way (untested).
To set it up :
• Open a new sheet named "Hidden".
• Enter the current lock date in cell A1.
• Hide the sheet.
Then:
VBA 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
And this in a normal module :
VBA Code:
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
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,214,591
Messages
6,120,427
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top