暂停 Outlook 给定的时间 [英] Pause Outlook for a given amount of time
本文介绍了暂停 Outlook 给定的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在收到电子邮件 10 秒后运行 Outlook 代码.
I'm trying to run Outlook code 10 seconds after an email is received.
我尝试使用 application.wait
,但您似乎无法使用 Outlook 执行此操作.
I tried using application.wait
but it appears that you cannot do this with Outlook.
如何在给定的时间内暂停 Outlook?
How do I pause Outlook for a given amount of time?
推荐答案
您可以创建一个 Sub 来模仿 Application.Wait
之类的东西.
You can create a Sub that will mimic the Application.Wait
, something like.
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'For 64-Bit
'Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Sub Pause(intSeconds As Variant)
' Comments: Waits for a specified number of seconds
' Params : intSeconds Number of seconds to wait
' Source : Total Visual SourceBook
On Error GoTo PROC_ERR
Dim datTime As Date
datTime = DateAdd("s", intSeconds, Now)
Do
' Yield to other programs (better than using DoEvents which eats up all the CPU cycles)
Sleep 100
DoEvents
Loop Until Now >= datTime
PROC_EXIT:
Exit Sub
PROC_ERR:
MsgBox "Error: " & Err.Number & ". " & Err.Description, , "Pause Method"
Resume PROC_EXIT
End Sub
要调用它,您可以使用 Pause 3
To call this you could use Pause 3
这篇关于暂停 Outlook 给定的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文