我编写了一个宏,该宏在第一次打开工作簿时在每个工作日的下午 15:30 运行。当工作簿关闭时,它会尝试在下次计划运行宏时自行打开。我试图将调度程序设置为 false,但出现错误。代码如下。有谁知道为什么这不起作用?
Private Sub Workbook_Open()
Application.OnTime TimeValue("15:30:00"), "MacroTimeTest"
End Sub
public dtime as date
Sub MacroTimeTest()
dtime = (Format(Application.Evaluate("workday(today(), 1)"), "DD/MM/YY") & " " & TimeValue("15:30:00"))
'other code has been deleted doesn't affect dtime variable
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'I have tried replacing false with 0 etc but it didn't make a difference
Application.OnTime earliesttime:=dtime, procedure:="MacroTimeTest", schedule:=False
End Sub