此问题已经完成(并已解决),请参阅Outlook VBA - Run a code every half an hour 几年前我使用了代码,在运行Vista(32位),Windows 7和Windows 8.1(全部64位)的几台计算机上没有遇到任何问题。安装了新Office 2010的新计算机存在一些问题。
64位版本的outlook似乎与32位版本的反应不同。 我对这些行感到错误
Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerfunc As Long) As Long
Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
这可以通过PtrSafe来纠正,如:
Declare Function PtrSafe SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerfunc As Long) As Long
Declare Function PtrSafe KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
行中出现另一个错误:
TimerID = SetTimer(0, 0, nMinutes, AddressOf TriggerTimer)
这些类型似乎有所不同。
答案 0 :(得分:0)
PtrSafe
没有更正代码,它只是声明可以从64位代码调用以下声明。
AddressOf
返回的指针原型为ByVal lpTimerfunc As Long
,为32位;即太小而无法容纳64位地址。 hwnd
也是如此。
使用LongPtr
类型来解决此问题。