|
楼主 |
发表于 2010-2-8 15:39
|
显示全部楼层
可以把以下语句加入thidworkbook 的代码中,F:\backup为放置文件夹backup的路径
Shell "cmd /k del F:\backup\*.* /f /q", vbHide
放入之后如下
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim strA As String
Shell "cmd /k del F:\宏晓店\销售\backup\*.* /f /q", vbHide
ThisWorkbook.Save
strA = "cmd.exe /c copy " & ThisWorkbook.FullName & " " & ThisWorkbook.Path & "\backup\" & VBA.Split(ThisWorkbook.Name, ".")(0) & Trim(Str(VBA.Year(Now) & VBA.Month(Now) & VBA.Day(Now) & VBA.Hour(Now) & VBA.Minute(Now) & VBA.Second(Now))) & ".xls /Y"
Call Shell(strA, vbHide)
End Sub
这样在backup文件中就只要保留最新的一个备份文件。 |
|