VBA 使用在所有版本的Office上均可使用的声明导入
示例
#If Vba7 Then
' It's important to check for Win64 first,
' because Win32 will also return true when Win64 does.
#If Win64 Then
Declare PtrSafe Function GetFoo64 Lib "exampleLib32" () As LongLong
#Else
Declare PtrSafe Function GetFoo Lib "exampleLib32" () As Long
#End If
#Else
' Must be Vba6, the PtrSafe keyword didn't exist back then,
' so we need to declare Win32 imports a bit differently than above.
#If Win32 Then
Declare Function GetFoo Lib "exampleLib32"() As Long
#Else
Declare Function GetFoo Lib "exampleLib"() As Integer
#End If
#End If根据您需要支持的Office版本,可以对此进行简化。例如,仍然没有多少人支持Office的16位版本。16位Office的最新版本是1994年发布的4.3版,因此以下声明对于几乎所有现代情况(包括Office2007)都是足够的。
#If Vba7 Then
' It's important to check for Win64 first,
' because Win32 will also return true when Win64 does.
#If Win64 Then
Declare PtrSafe Function GetFoo64 Lib "exampleLib32" () As LongLong
#Else
Declare PtrSafe Function GetFoo Lib "exampleLib32" () As Long
#End If
#Else
' Must be Vba6. We don't support 16 bit office, so must be Win32.
Declare Function GetFoo Lib "exampleLib32"() As Long
#End If如果您不需要支持Office2010之前的任何版本,则此声明可以正常工作。
' We only have 2010 installs, so we already know we have Vba7.
#If Win64 Then
Declare PtrSafe Function GetFoo64 Lib "exampleLib32" () As LongLong
#Else
Declare PtrSafe Function GetFoo Lib "exampleLib32" () As Long
#End If
热门推荐
7 简短的二胎祝福语
10 简短霸气女儿生日 祝福语
11 祝福语高考小众诗句简短
12 元旦祝福语20秒简短
13 老师过年祝福语大全 简短
14 一生祝福语简短
15 产检祝福语简短霸气
16 朋友店开张祝福语简短
17 生日爱情祝福语大全简短
18 朋友女儿生日祝福语 简短