2013-10-05 12 views
7

Mam prosty kod VBA w programie Outlook 2010, który automatycznie drukuje przychodzące wiadomości e-mail.Outlook Poczekaj kilka sekund, a następnie wykonaj

Ten skrypt jest uruchamiany za każdym razem, gdy e-mail wchodzi przez regułę.

Oto kod:

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

Jak mogę dokonać tego skryptu odczekaj 10 sekund, a następnie uruchom go. Muszę coś takiego:

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

Odpowiedz

12

Spróbuj:

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 

czyli

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 

czyli

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

dzięki dużo @theghostofc – RaduS

+0

tylko szybki Add- na pytanie z ciekawości, czy wiesz, jak ca n czy to się stanie przed Sub? – RaduS

+0

@RaduS, nie wiem jak wykonać 'sub's z regułami. Uważam, że musisz określić 'sub' do wykonania dla tej reguły. W takim przypadku wylądujesz ponownie;) –

Powiązane problemy