如何使VBA代码与Office 2010兼容-64位版本和较旧的Office版本 [英] how to make VBA code compatible for office 2010 - 64 bit version and older office versions

查看:570
本文介绍了如何使VBA代码与Office 2010兼容-64位版本和较旧的Office版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have observed an issue with below function call when we migrated to office 2010-64 bit version.

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位版本上可以正常使用.

According to information available on http://msdn.microsoft.com/en-us/library/ee691831.aspx link. I have changed above call as below and it has been working fine on office 2010 64 bit version.

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

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

The problem is, I need to make same call to work on older office versions as well and it throws compile error on older versions.

任何人都不知道如何使此呼叫适用于Office 2010和更早的Office版本.

Has anyone any idea how to make this call working for office 2010 and older office versions.

推荐答案

正如MSDN文章所述,请使用条件编译:它对我来说在Excel 97到Excel 2010 32位& 64位.

As the MSDN article says, use conditional compilation: it works well for me in Excel 97 through Excel 2010 32-bit & 64-bit.

#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代码与Office 2010兼容-64位版本和较旧的Office版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆