gpt4 book ai didi

vba - 如何使VBA代码与Office 2010兼容-64位版本和较旧的Office版本

转载 作者:行者123 更新时间:2023-12-04 17:05:00 24 4
gpt4 key购买 nike

当我们迁移到Office 2010-64位版本时,我发现以下函数调用存在问题。

Private Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

根据 http://msdn.microsoft.com/en-us/library/ee691831.aspx链接上的可用信息。我已经按如下方式更改了上述调用,并且在Office 2010 64位版本上运行良好。
Private Declare PtrSafe Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

问题是,我还需要进行相同的调用才能在较旧的Office版本上工作,并且在较旧的版本上会引发编译错误。

有谁知道如何使此调用适用于Office 2010和较早的Office版本。

最佳答案

正如MSDN文章所述,请使用条件编译:它对于Excel 97至Excel 2010(32位和64位)非常有效。

#If VBA7 Then
Private Declare PtrSafe Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
#Else
Private Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
#End if

关于vba - 如何使VBA代码与Office 2010兼容-64位版本和较旧的Office版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4251111/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com