ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   autodestruction (https://www.excelbanter.com/excel-programming/285446-autodestruction.html)

douvid

autodestruction
 
Hi,
I try to protect my file from users modifying data.
Is there a way I can delete a file when I see they have change the data according to a specific date ??
I know it is strange but I need this to avoid corrupted files

TK
Douvid

Bill Manville

autodestruction
 
Douvid wrote:
Is there a way I can delete a file when I see they have change the data
according to a specific date ??


Not sure what you mean by "according to a specific date"
In VBA you can find out the "last modified" date for a file using the FileDateTime function.
If the file is open (other than read-only) in Excel then this date will be misleading as it is
set to when the file was opened.

You can use the Kill statement to delete a file.

So

If FileDateTime("C:\MyFile.ext")DateSerial(2003,1,1) Then
Kill "C:\MyFile.ext"
End If


Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup



All times are GMT +1. The time now is 06:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com