用EXCEL写一个宏.每天自动以日期时间为文件名保存怎么写?

用EXCEL写一个宏.每天自动以日期时间为文件名保存怎么写?
我没写过宏。。也不会写宏,请大虾们直接给一个好吗?

Sub 按钮1_单击()
Application.ScreenUpdating = False
Application.EnableEvents = False

With Application.FileSearch
.LookIn = ThisWorkbook.Path
.Filename = Format(Date, "yyyymmdd") & "*.xls"
If .Execute(SortBy:=msoSortByFileName, SortOrder:=msoSortOrderAscending) > 0 Then
ActiveSheet.Copy
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & Format(Date, "yyyymmdd") & Format(.FoundFiles.Count + 1, "-000") & ".XLS"
Else
ActiveSheet.Copy
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & Format(Date, "yyyymmdd") & "-001.XLS"
End If
If MsgBox("是否关闭已经生成的文件?", vbYesNo, "请选择!") = vbYes Then ActiveWorkbook.Close
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-05-21
自己录制一定行代码就ok了本回答被提问者采纳