如何用VBA实现excel表格编辑完关闭前自动以原文件名加系统日期及编号命名另存到指定途径

2024-11-15 14:10:41
推荐回答(3个)
回答1:

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

亲测可用,请采纳

回答2:

workbook 的close事件中加上保存命令。

回答3:

到宏里边去学一段程序就可以了