【问题标题】:Outlook Wait a few seconds then executeOutlook 等待几秒钟然后执行
【发布时间】:2013-10-05 09:57:09
【问题描述】:

我在 Outlook 2010 中有一个简单的 VBA 代码,它可以自动打印任何传入的电子邮件。

此脚本设置为在每次通过规则收到电子邮件时运行。

代码如下:

Sub printradu(Item As Outlook.MailItem)
       MessageAndAttachmentProcessor Item, True
End Sub

我怎样才能让这个脚本等待 10 秒然后执行它。我需要这样的东西:

Sub printradu(Item As Outlook.MailItem)
       'Wait 10 seconds then execute the code below:
       MessageAndAttachmentProcessor Item, True
End Sub

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    试试:

    Sub printradu(Item As Outlook.MailItem)
        'Wait 10 seconds then execute the code below:
        Application.Wait(Now + TimeValue("0:00:10"))
        MessageAndAttachmentProcessor Item, True
    End Sub
    

    或者:

    Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Sub printradu(Item As Outlook.MailItem)
        'Wait 10 seconds then execute the code below:
        Sleep(10000)
        MessageAndAttachmentProcessor Item, True
    End Sub
    

    或者:

    Sub printradu(Item As Outlook.MailItem)
        'Wait 10 seconds then execute the code below:
        Threading.thread.sleep(10000)
        MessageAndAttachmentProcessor Item, True
    End Sub
    

    【讨论】:

    • 非常感谢@theghostofc
    • 只是出于好奇而提出的一个快速附加问题,你知道我怎样才能在 Sub 之前做到这一点吗?
    • @RaduS,我不知道如何使用规则执行subs。我相信您必须指定一个sub 才能执行该规则。在这种情况下,这将是您再次降落的地方;)
    • 我的意思是...有什么办法可以在子启动前插入 10 秒的等待时间?因为现在等待时间在子内。
    • 1000 毫秒只有 1 秒 ;)
    【解决方案2】:

    这在 Outlook 2013 VBA 中对我有用(出于某种原因,我必须在“Application.Wait”之前包含“outlook.”):

    Outlook.Application.Wait (Now + TimeValue("0:00:5"))
    

    【讨论】:

      猜你喜欢
      • 2022-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-21
      • 1970-01-01
      • 1970-01-01
      • 2019-10-13
      • 1970-01-01
      相关资源
      最近更新 更多