0

如果可执行文件可用,我有一个运行命令提示符的宏。在检查可执行文件是否可用之前,宏会等待 5 分钟。问题是这个锁很出色。我更愿意做的是将控制权交还给用户五分钟。

这就是这段代码目前的样子。

Do Until TuflowEx < Range("Exe").Value ' Check if number of executables running is less than the user specified maximum
    Application.Wait (Now + TimeValue("0:05:00")) ' Wait 5 minutes before checking again
    TuflowEx = TuEx() ' Run TuEx to get the currently active number of executables
Loop

干杯

4

1 回答 1

1

请改用Application.Ontime

只需创建一个例程来进行检查,如果检查成功,让它恢复你的逻辑。

Sub ChecktuflowEx()
    If TuEx() => Range("Exe").Value Then
        'whatever you want
    Else
        'Check again in 5 minutes.
        Application.OnTime Now + TimeValue("0:05:00"), "ChecktuflowEx"
    End If
End Sub
于 2012-11-08T21:58:10.603 回答