删除备份文件超过5天?

时间:2014-03-14 10:49:05

标签: vba datetime

我无法弄清楚如何以编程方式删除这些excel文件,比如它们是5天(5个工作日)还是更旧。我能够弄清楚如果它们比当前日期早5天但是周末和假日等等,则删除它们 未删除。

非常感谢任何帮助,

这里是备份excel文件的代码。

Dim backupfolder As String
    backupfolder = "E:/CLIENTS/ExcelBackup/BackupJM/"

Dim savedate
    savedate = Date ' Current system date

Dim savetime
    savetime = Time ' Current system time

Dim formattime As String
    formattime = Format(savetime, "hh.mm.ss")

 Dim formatdate As String
    formatdate = Format(savedate, "DD-MM-YYYY")

Application.DisplayAlerts = False
    'Application.Run ("Auto_Save")

ActiveWorkbook.SaveCopyAs fileName:=backupfolder & formatdate & " " & formattime & " " & 

ActiveWorkbook.Name

 ActiveWorkbook.Save

Application.DisplayAlerts = True

 MsgBox "Backup Run. Please Check at: " & backupfolder

0 个答案:

没有答案