延迟Excel保存功能 [英] Delay Excel save function
本文介绍了延迟Excel保存功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个工作簿,需要在开始时进行保存,然后每5分钟自动保存一次,但是我需要延迟初始保存,以便在工作簿打开时等待30秒,然后进行保存.
I have a workbook which requires to be saved at the beginning then auto saving every 5 mins, but i need to delay the initial save so that when the workbook opens it waits 30secs then does the save.
这是我拥有的代码,但它会自动运行:
This is the code i have, but it runs it automatically:
Private Sub Workbook_Open()
Time = Now() + TimeValue("00:00:30")
Application.OnTime Time, "WaitUntilReady"
Public Sub WaitUntilReady()
savefolder = "C:\Users\" & Environ$("Username") & "\Desktop\"
mypath = savefolder & Format(Date, "dd-mmm-yy")
If Len(Dir(mypath, vbDirectory)) = 0 Then MkDir mypath
On Error Resume Next
ThisWorkbook.SaveAs mypath & "\" & "Practice Monitoring Template" & " - " & Format(Time, "hh.nn") & ".xlsm"
Application.EnableEvents = True
End Sub
推荐答案
Time
是Excel中的保留字(它返回 current 时间),请改用此格式:
Time
is reserved word in Excel (it returns current time), use this one instead:
Private Sub Workbook_Open()
Application.OnTime Now() + TimeValue("00:00:30"), "WaitUntilReady"
End Sub
这篇关于延迟Excel保存功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文