你试试在“workbook"的 Private Sub Workbook_BeforeClose(Cancel As Boolean) 中加入如下句子:
myNowTime = Format(Now, "yymmdd" &"-" & "hhmmss")
ActiveWorkbook.SaveAs Filename:=currPath & myNowTime &".xls", AddToMru:=False ‘(”currPath“为你的路径及文件名称)
excel自动另存需要编写宏函数。
可以在ThisWorkBook对象中输入代码完成,
代码如下:
Private Sub Workbook_BeforeClose(Cancel As Boolean) ActiveWorkbook.SaveAs Filename:="C:\aaa.xls", _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False End Sub
其中C:\aaa.xls就是所备份的文件的路径。
ActiveWorkbook.SaveAs Filename:= _
ThisWorkbook.Path & "\" & Format(Date, "yyyy-MM-dd hh:mm:ss") ,FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
例子语句:
ActiveWorkbook.SaveAs Format(Now(), "yyyymmdd")