excel - 在 Excel 中声明 PtrSafe 兼容性

标签 excel vba

我在 VBA 中使用此语句

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

这适用于:

  • Win 64 位、Excel 2010 64 位
  • Win 64 位、Excel 1010 32 位

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

我不知道为什么会发生这种情况。有什么想法吗?

最佳答案

好的,我已经重写了这个:

#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 的行为方式吗?

关于excel - 在 Excel 中声明 PtrSafe 兼容性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26822004/

相关文章:

sql - 根据 Excel 用户表单下拉组合框中选定的月份创建 SQL 查询

excel - 仅当值超过 45 时才求和,如果小于 45,则不在底部单元格上显示值

c# - 一些 Excel 单元格保持未填充状态,使用 C#

excel - 由于公式,工作表速度慢和崩溃

vba - 简报 VBA : How to get last used column in a row from an Excel sheet

vba - 如何将电子表格中的单元格设置为只读?

excel - 如何在Excel VBA中进行多重转置

arrays - 使用数组 VBA 初始化对象

regex - 如何用@ 替换 'at'

excel - 在 Excel 中查找多个文本