0
我已經使用方法Application.ontime()來調度一些宏。關閉工作簿後,它會一次又一次地打開。爲了克服這個問題,我在工作簿上設置了另一個事件 - BeforeClosed。現在它顯示運行時錯誤1004:'對象'應用程序的'OnTime'方法失敗。我沒有得到爲什麼這種情況發生後,甚至從Web重新獲得幫助上下文。下面的代碼給出。Excel工作簿在關閉後重復打開
Private Sub Workbook_Open()
starttime = Now + TimeValue("00:02:00")
Application.OnTime EarliestTime:=starttime, Procedure:="startapp", schedule:=True
rtime = TimeValue("14:30:00")
Application.OnTime EarliestTime:=rtime, Procedure:="sendreminder", Schedule:=True
Application.OnTime EarliestTime:=rtime, Procedure:="sendreminder_out",Schedule:=True
Application.OnTime EarliestTime:=rtime, Procedure:="SendReminderFromProxy",Schedule:=True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "Dear" & " " & Environ("USERNAME") & ", " & "Please do not forget to save before closing."
starttime = Now + TimeValue("00:02:00")
Application.OnTime EarliestTime:=starttime, Procedure:="startapp", Schedule:=False
rtime = TimeValue("14:30:00")
Application.OnTime EarliestTime:=rtime, Procedure:="sendreminder", Schedule:=False
Application.OnTime EarliestTime:=rtime, Procedure:="sendreminder_out", Schedule:=False
Application.OnTime EarliestTime:=rtime, Procedure:="SendReminderFromProxy", Schedule:=False
End Sub
我試過使用上面的代碼。它仍然顯示錯誤。 – Pooja
哪一行給出錯誤? –
from workbook_BeforeClose()line- Application.OnTime EarliestTime:= starttime,Procedure:=「startapp」,Schedule:= False – Pooja