亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Outlook VBA-每半小時運行一次代碼

Outlook VBA-每半小時運行一次代碼

我想每半小時在Outlook(VBA)中運行一個特定的代碼。而且,在代碼運行時,Outlook用戶也不應受到打擾。它應僅在后端運行。有一個名為的事件Application_Reminder。它在Outlook中每次出現提醒時運行。但這仍然涉及用戶交互。我想要一個完整的后端程序。
查看完整描述

3 回答

?
慕運維8079593

TA貢獻1876條經驗 獲得超5個贊

對于Win64,我需要將其更改為:


Declare PtrSafe Function SetTimer Lib "user32" (ByVal hwnd As LongLong, ByVal nIDEvent As LongLong, ByVal uElapse As LongLong, ByVal lpTimerfunc As LongLong) As LongLong

Declare PtrSafe Function KillTimer Lib "user32" (ByVal hwnd As LongLong, ByVal nIDEvent As LongLong) As LongLong


Public TimerID As LongLong 'Need a timer ID to eventually turn off the timer. If the timer ID <> 0 then the timer is running


Public Sub TriggerTimer(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idevent As Long, ByVal Systime As Long)

  MsgBox "The TriggerTimer function has been automatically called!"

End Sub



Public Sub DeactivateTimer()

Dim lSuccess As LongLong

  lSuccess = KillTimer(0, TimerID)

  If lSuccess = 0 Then

    MsgBox "The timer failed to deactivate."

  Else

    TimerID = 0

  End If

End Sub


Public Sub ActivateTimer(ByVal nMinutes As Long)

  nMinutes = nMinutes * 1000 * 60 'The SetTimer call accepts milliseconds, so convert to minutes

  If TimerID <> 0 Then Call DeactivateTimer 'Check to see if timer is running before call to SetTimer

  TimerID = SetTimer(0, 0, nMinutes, AddressOf TriggerTimer)

  If TimerID = 0 Then

    MsgBox "The timer failed to activate."

  End If

End Sub


查看完整回答
反對 回復 2019-10-30
?
12345678_0001

TA貢獻1802條經驗 獲得超5個贊

更正64位的上限答案:


Declare PtrSafe Function SetTimer Lib "user32" (ByVal hwnd As LongLong, ByVal nIDEvent As LongLong, ByVal uElapse As LongLong, ByVal lpTimerfunc As LongLong) As LongLong

Declare PtrSafe Function KillTimer Lib "user32" (ByVal hwnd As LongLong, ByVal nIDEvent As LongLong) As LongLong


Public TimerID As LongLong 'Need a timer ID to eventually turn off the timer. If the timer ID <> 0 then the timer is running


Public Sub TriggerTimer(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idevent As Long, ByVal Systime As Long)

  MsgBox "The TriggerTimer function has been automatically called!"

End Sub



Public Sub DeactivateTimer()

Dim lSuccess As LongLong              '<~ Corrected here

  lSuccess = KillTimer(0, TimerID)

  If lSuccess = 0 Then

    MsgBox "The timer failed to deactivate."

  Else

    TimerID = 0

  End If

End Sub


Public Sub ActivateTimer(ByVal nMinutes As Long)

  nMinutes = nMinutes * 1000 * 60 'The SetTimer call accepts milliseconds, so convert to minutes

  If TimerID <> 0 Then Call DeactivateTimer 'Check to see if timer is running before call to SetTimer

  TimerID = SetTimer(0, 0, nMinutes, AddressOf TriggerTimer)

  If TimerID = 0 Then

    MsgBox "The timer failed to activate."

  End If

End Sub


查看完整回答
反對 回復 2019-10-30
  • 3 回答
  • 0 關注
  • 1093 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號