|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
可以试试看
- Private Sub Workbook_BeforeClose(Cancel As Boolean)
- Dim fileName As String
-
- Dim wkbkName As String
-
- On Error Resume Next
-
- wkbkName = ThisWorkbook.Name
-
- If wkbkName Like "*-*-*-*" Then
-
- fileName = ThisWorkbook.Path & "" & Left$(wkbkName, InStr(wkbkName, "-")) & Format(Now(), "yyyy-mm-dd") & ".xls"
-
- Else
-
- fileName = ThisWorkbook.Path & "" & Left$(wkbkName, InStrRev(wkbkName, ".") - 1) & "-" & Format(Now(), "yyyy-mm-dd") & ".xls"
-
- End If
-
- ThisWorkbook.SaveAs fileName
-
- Kill ThisWorkbook.Path & "" & wkbkName
- End Sub
复制代码 |
|