Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
n = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 5)
fname = Application.GetSaveAsFilename(CStr(n) & Format(Now(), "yy/mm/dd"), fileFilter:="Excel文件(*.xls),*.xls", Title:=选择保存路径)
If fname = False Then Exit Sub
ThisWorkbook.SaveAs fname
Application.DisplayAlerts = True
End Sub
亲测可用,请采纳
workbook 的close事件中加上保存命令。
到宏里边去学一段程序就可以了