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

查看:111
本文介绍了如何使 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)

问题是,我也需要在旧的办公版本上进行相同的调用,它会在旧版本上引发编译错误.

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天全站免登陆