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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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
@Macropod.....Agreed....I found out the hard way, early on in my Excel Journey...(y)
 
Upvote 0

Forum statistics

Threads
1,216,130
Messages
6,129,058
Members
449,484
Latest member
khairianr

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