VBA Excel WideCharToMultiByte Compile error on 64-bit System
Compile Error:
The code in this project must be updated for use on64-bit systems.
Please review and update Declare statements and then mark them with the PtrSafe attribute.
1.问题:
32-bit的VBA程序,在64-bit系统上运行时,出现该编译错误。
环境:Office2010 Excel 64-bit, 64-bit Win7 OS
2.原因
原程序中,函数声明如下。该函数在32-bit系统中编译、运行没有问题。但是在64-bit系统中会出现编译错误。
Private Declare Function WideCharToMultiByte Lib "kernel32" _
(ByVal CodePage As Long, ByVal dwFlags As Long, lpWideCharStr As Integer, ByVal cchWideChar As Long, _
lpMultiByteStr As Byte, ByVal cchMultiByte As Long, ByVal lpDefaultChar As String, ByVal lpUsedDefaultChar As Long) As Long
3.修改
其实,提示信息中,已经说明的很清楚了。
只要在函数的声明处添加"PtrSafe"属性(无需修改其他地方),程序就正常了。
修改后程序:
Private Declare PtrSafe
Function WideCharToMultiByte Lib "kernel32" _
(ByVal CodePage As Long, ByVal dwFlags As Long, lpWideCharStr As Integer, ByVal cchWideChar As Long, _
lpMultiByteStr As Byte, ByVal cchMultiByte As Long, ByVal lpDefaultChar As String, ByVal lpUsedDefaultChar As Long) As Long
4.扩展
①PtrSafe<Keyword>
https://msdn.microsoft.com/en-us/library/office/gg278832.aspx?f=255&MSPPError=-2147217396
Declare statements with the PtrSafe keyword is the recommended syntax. Declare statements that include PtrSafe work correctly in the VBA7 development environment on both 32-bit and 64-bit platforms only after all data types in the Declare statement (parameters and return values) that need to store 64-bit quantities are updated to use LongLong for 64-bit integrals or LongPtr for pointers and handles. To ensure backwards compatibility with VBA version 6 and earlier use the following construct:
②LongPtr Data Type
https://msdn.microsoft.com/en-us/library/office/gg251378.aspx?f=255&MSPPError=-2147217396
LongPtr (Long integer on 32-bit systems, LongLong integer on 64-bit systems) variables are stored as signed 32-bit (4-byte) numbers ranging in value from -2,147,483,648 to 2,147,483,647 on 32-bit systems; and signed 64-bit (8-byte) numbers ranging in value from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 on 64-bit systems.
VBA Excel WideCharToMultiByte Compile error on 64-bit System的更多相关文章
- 一种简单有效的VBA源代码加密办法,支持64位宿主,适用于大部分VBA代码加密
原始出处:http://www.cnblogs.com/Charltsing/p/EncryptVBACode.html VBA代码加密是个老生常谈的问题,自从本人的VBA Dumper发布之后,在O ...
- Data Flow ->> Excel Connection遇到错误:[Excel Source [16]] Error: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.....
在SSIS下做Excel导入数据的时候遇到下面的错误 [Excel Source [16]] Error: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONF ...
- FreeModbus LINUXTCP Compile ERROR
/********************************************************************************* * FreeModbus LINU ...
- OK335xS canutils deal with compile error
/************************************************************************************** * OK335xS ca ...
- Error:(12, 64) java: 未报告的异常错误java.io.IOException; 必须对其进行捕获或声明以便抛出
Error:(12, 64) java: 未报告的异常错误java.io.IOException; 必须对其进行捕获或声明以便抛出 package com.test; import org.apach ...
- Handling CLIK AS3 Compile Error 1152 & 5000
Handling CLIK AS3 Compile Error 1152 & 5000 Action You add a CLIK AS3 component from CLIK_Compon ...
- Android error:No CPU/ABI system image available for this target
原文:Android error:No CPU/ABI system image available for this target No CPU/ABI system image available ...
- error: could not create '/System/Library/Frameworks/Python.framework/Versions/2.7/share': Operation not permitted
参考: Python pip安装模块报错 Mac升级到EI Captain之后pip install 无法使用问题 error: could not create '/System/Library/F ...
- SecureCRT connecting VM Linux show error message: The remote system refused the connection.
SecureCRT connecting VM Linux show error message: The remote system refused the connection.
随机推荐
- BZOJ 1486: [HNOI2009]最小圈 [01分数规划]
裸题...平均权值最小的环.... 注意$dfs-spfa$时$dfs(cl)$...不要写成$dfs(u)$ #include <iostream> #include <cstdi ...
- BZOJ 3238: [Ahoi2013]差异 [后缀自动机]
3238: [Ahoi2013]差异 Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 2512 Solved: 1140[Submit][Status ...
- Linux设置系统运行模式
Linux系统有7个运行级别(runlevel): 运行级别0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动 运行级别1:单用户工作状态,root权限,用于系统维护,禁止远程登陆 运行级 ...
- 基于Citus和ASP.NET Core开发多租户应用
Citus是基于PsotgreSQL的扩展,用于切分PsotgreSQL的数据,非常简单地实现数据“切片(sharp)”.如果不使用Citus,则需要开发者自己实现分布式数据访问层(DDAL),实现路 ...
- 线性一致性与全序广播------《Designing Data-Intensive Applications》读书笔记12
上一篇聊了聊构建分布式系统所面临的困难,这篇将着重讨论构建容错分布式系统的算法与协议.构建容错系统的最佳方法是使用通用抽象,允许应用程序忽略分布式系统中的一些问题.本篇我们先聊一聊线性一致性,以及与线 ...
- PLEC-交流电机系统+笔记
1.固有机械特性近似图 2.三相交流电机的控制系统 1)理论推导 第一次制动选择能耗制动,第二次制动选择倒拉制动. 2)模型搭建 3)模拟仿真 3.心得体会和笔记总结 制动方式的选择主要是根据各个制动 ...
- Apollo学习
Apollo的配置 参考: Apollo 配置详细步骤(Windows环境) MQTT再学习 -- 搭建MQTT服务器及测试 分布式部署指南 Java客户端使用指南
- HTTPS的原理解析
http://www.cnblogs.com/alisecurity/p/5939336.html 外加文档
- PHP实现WebService的简单示例和实现步骤
首先我创建的文件有: api.php api的接口类文件 api.wsdl 我创建产生的最后要调用的接口文件 cometrue.php 注册service api类内容的所有内容的执行文件 creat ...
- Sql Server 常用事务处理总结
在数据库操作中,常用事务写法: 1. 通过 @@error 判断一批sql 执行完毕,是否有异常. @@error 为系统变量,每次执行完 sql 都会返回一个数值, 0 表示 执行成功 ,非0 ...