- 帖子
- 3
- 主題
- 1
- 精華
- 0
- 積分
- 5
- 點名
- 0
- 作業系統
- MS
- 軟體版本
- Win 7
- 閱讀權限
- 10
- 註冊時間
- 2015-2-7
- 最後登錄
- 2015-2-7
|
2#
發表於 2015-2-7 11:50
| 只看該作者
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 |
|