在给定的时间内暂停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?
推荐答案
您可以创建一个模仿Application.Wait
的Sub,类似于.
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屋!
查看全文