Excel 2016 年带 32 位标志的条件编译

Excel 2016 conditional compilation with 32-bit flags

今天通过更新得到的Excel 2016 64位新版本中,在检查不符合条件的函数定义时,似乎没有遵循条件编译定义了 PtrSafe(对于 32 位平台就是这种情况)。在这个例子中,我们对不同平台的同一个函数有不同的定义,当 Excel 加载加载项时它死了,并抱怨第三个定义在函数声明中没有 PtrSafe(当然它没有'因为它适用于 32 位平台)。

有没有办法让Excel在VBA中遇到这段代码时不死?或者这只是 OSX 上 64 位 Excel 2016 中的一个错误?对我来说似乎是一个明显的错误。我在哪里报告 Excel 中的错误?

#If Mac Then
' Even though the functions are exported with a leading underscore, Excel 2011 for Mac doesn't want the leading underscore as part of name
Private Declare PtrSafe Function get_global_param_string_private Lib "libCoolProp.dylib" Alias "get_global_param_string" (ByVal param As String, ByVal Output As String, ByVal n As Integer) As Long
#ElseIf Win64 Then
Private Declare PtrSafe Function get_global_param_string_private Lib "CoolProp_xls_x64.dll" Alias "get_global_param_string" (ByVal param As String, ByVal Output As String, ByVal n As Integer) As Long
#Else
Private Declare Function get_global_param_string_private Lib "CoolProp_xls_std.dll" Alias "_get_global_param_string@12" (ByVal param As String, ByVal Output As String, ByVal n As Integer) As Long
#End If

除非 API 函数本身对于 64 位和 32 位是不同的 windows 对于 Windows 使用 VBA7 开关(从 Office 2010 开始)就足够了:

#If Mac Then
' Even though the functions are exported with a leading underscore, Excel 2011 for Mac doesn't want the leading underscore as part of name
Private Declare PtrSafe Function get_global_param_string_private Lib "libCoolProp.dylib" Alias "get_global_param_string" (ByVal param As String, ByVal Output As String, ByVal n As Integer) As Long
#ElseIf VBA7 Then
Private Declare PtrSafe Function get_global_param_string_private Lib "CoolProp_xls_x64.dll" Alias "get_global_param_string" (ByVal param As String, ByVal Output As String, ByVal n As Integer) As Long
#Else
Private Declare Function get_global_param_string_private Lib "CoolProp_xls_std.dll" Alias "_get_global_param_string@12" (ByVal param As String, ByVal Output As String, ByVal n As Integer) As Long
#End If