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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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