Help to set expired day to open excel file

nhnn1986

Board Regular
Joined
Oct 12, 2017
Messages
92
Hi all

I have workbook shared to someone, but I want this excel file can open if the day before 31/12/2019. If file open on day after 31/12/2019 will have pop up messegbox "File was experidated" then delete this file when user click "OK" button in Pop up.

Please help me to do that, thanks./.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Use something like this....BUT....if the Other User disables macros the file will NOT be deleted

Code:
Private Sub Workbook_Open()
Dim Edate As Date
Edate = Format("31/12/2019", "DD/MM/YYYY") ' Replace this with the date you want
If Date > Edate  Then
MsgBox "This workbook is Expired and will now close !!!"
With ThisWorkbook
        .Saved = True
        .ChangeFileAccess Mode:=xlReadOnly
        Kill .FullName
        .Close False
    End With
End If
End Sub
 
Last edited:
Upvote 0
And, if you've supplied the file via email, for example, or the user has made backups, they'll soon know to reload the original and disable your macro (even permanently, by saving the file in the xlsx format).
 
Upvote 0
Short answer....No !!
Unless of course you simply reach the expiry date and delete the file manually
 
Last edited:
Upvote 0
Long story short: anything you can do to lock down a workbook you're giving others access to can be defeated without too much difficulty by a determined user. Excel's security in such situations might best be viewed as something designed to protect a trustworthy but ignorant user from themselves...
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

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