返回列表 上一主題 發帖

[發問] 存檔時自動備份檔案並轉為.xlsx格式

回復 1# msmplay
  1. Private Sub Workbook_BeforeClose(Cancel As Boolean)
  2. Dim mypath As String, fname As String
  3. fname = "自動備份" & Format(Date, "yymmdd") & ".xlsx"
  4. mypath = ThisWorkbook.Path & "\備份\"
  5. ThisWorkbook.SaveAs mypath & fname, FileFormat:=xlOpenXMLWorkbook
  6. End Sub
複製代碼

TOP

回復 4# msmplay
  1. Private Sub Workbook_BeforeClose(Cancel As Boolean)
  2. Dim mypath As String, fname As String
  3. fname = "自動備份" & Format(Date, "yymmdd") & ".xlsx"
  4. mypath = ThisWorkbook.Path & "\備份\"
  5. Application.DisplayAlerts = False '關閉系統警告訊息
  6. ThisWorkbook.Save '要儲存自身檔案,請自行選擇要不要儲存
  7. ThisWorkbook.SaveAs mypath & fname, FileFormat:=xlOpenXMLWorkbook
  8. Application.DisplayAlerts = True '開啟系統警告訊息
  9. End Sub
複製代碼

TOP

        靜思自在 : 為人處世要小心細心,但不要「小心眼」。
返回列表 上一主題