在Excel中声明PtrSafe兼容性

时间:2014-11-08 20:56:49

标签: excel vba

我在VBA中使用此语句

Private Declare PtrSafe Function GetTimeZoneInformationAny Lib "kernel32" Alias _
  "GetTimeZoneInformation" (buffer As Any) As Long

这适用于:

  • 赢得64位,Excel 2010 64位
  • 赢得64位,Excel 1010 32位

但是我的客户报告了单词PtrSafe的编译错误。他正在使用Excel 2010。

我不确定为什么会这样。任何想法?

1 个答案:

答案 0 :(得分:3)

好的我重写了这个:

#If VBA7 Then
Private Declare PtrSafe Function GetTimeZoneInformationAny Lib "kernel32" Alias "GetTimeZoneInformation" (buffer As Any) As Long
#Else
Private Declare Function GetTimeZoneInformationAny Lib "kernel32" Alias "GetTimeZoneInformation" (buffer As Any) As Long
#End If

这在Excel 2010 64位的第二行上出现了编译错误,并且该行仍然是红色的,但是当我再次编译时,错误不再显示。这是Excel的行为吗?