返回列表 上一主題 發帖

EXCEL 定時依日期自動另存新檔

EXCEL 定時依日期自動另存新檔

請教各位,

如何讓EXCEL 定時依日期自動另存新檔

謝謝

請問如何設定另存新檔的時間。
我需要每幾天另存新檔
我試過在WaitSec 調整但儲存時間好像都不是固定
THX

TOP

wl02353427大大曾經發表過以下程序,但如何將該程序另存新檔時,巨集也不會同時儲存

在工作表1 or ThisWorkbook下:
Private Sub CommandButton1_Click()
startTimer
End Sub

Private Sub CommandButton2_Click()
stopTimer
End Sub

在模組當中:
Sub startTimer()
Application.OnTime Now + TimeValue("00:00:01"), "Increment_count"
End Sub

Sub Increment_count()
hiji = Now()
Range("A1") = hiji

WaitSec = 30 '延遲時間

NameOfThisProcedure = "儲存程序"

NextTime = hiji + TimeSerial(0, 0, WaitSec)

Application.OnTime EarliestTime:=NextTime, Procedure:=NameOfThisProcedure, LatestTime:=NextTime

startTimer
End Sub

Sub 儲存程序()
  ThisWorkbook.SaveAs ThisWorkbook.Path & "\" & Format(Now, "yyyymmdd") & ".xls"
End Sub

TOP

        靜思自在 : 甘願做、歡喜受。
返回列表 上一主題