ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 2908|回复: 6

[求助] 若要在64位系统上使用,则必须更新此项目中的代码。请检查并更新Declare语句,然后用...

[复制链接]

TA的精华主题

TA的得分主题

发表于 2021-1-13 15:31 | 显示全部楼层 |阅读模式
本帖最后由 wally926 于 2021-1-13 15:32 编辑

WIN10  OFFICE 2013  API 出现错误提示
编译错误:
若要在64位系统上使用,则必须更新此项目中的代码。请检查并更新Declare语句,然后用Ptrsafe属性标记它们
请求修改代码:


Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" _
(ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2 '表示把窗体设置为半透明样式
Private Const LWA_COLORKEY = &H1 '表示不显示窗体中的透明色
Dim hWndForm As Long
Dim hWndXls As Long
Dim iStyle As Long

报错.png

TA的精华主题

TA的得分主题

发表于 2021-1-15 17:08 | 显示全部楼层
改为以下格式
#If VBA7 And Win64 Then
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongLong
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As LongLong, ByVal nIndex As LongLong) As LongLong
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As LongLong, ByVal nIndex As LongLong, ByVal dwNewLong As LongLong) As LongLong
Private Declare Function SetLayeredWindowAttributes Lib "user32" _
(ByVal hWnd As LongLong, ByVal crKey As LongLong, ByVal bAlpha As Byte, ByVal dwFlags As LongLong) As LongLong
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2 '表示把窗体设置为半透明样式
Private Const LWA_COLORKEY = &H1 '表示不显示窗体中的透明色
Dim hWndForm As Long
Dim hWndXls As Long
Dim iStyle As Long
#Else
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" _
(ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = &H2 '表示把窗体设置为半透明样式
Private Const LWA_COLORKEY = &H1 '表示不显示窗体中的透明色
Dim hWndForm As Long
Dim hWndXls As Long
Dim iStyle As Long
#End If

TA的精华主题

TA的得分主题

发表于 2024-8-10 11:02 | 显示全部楼层
我都没看出区别来,就是加了个判断还有类型格式么

TA的精华主题

TA的得分主题

发表于 2024-8-10 12:03 | 显示全部楼层
y1983y 发表于 2021-1-15 17:08
改为以下格式
#If VBA7 And Win64 Then
Private Declare Function FindWindow Lib "user32" Alias "FindW ...

有32和64位API互转工具吗?可以也可以搜索的那种

TA的精华主题

TA的得分主题

发表于 2024-8-10 13:34 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助
你原来写的声明,只能在32位系统上使用。如果要在64位系统上使用,就要在每个 Declare 单词的后面添加一个单词 PtrSafe 。这样电脑就懂了。

TA的精华主题

TA的得分主题

发表于 2024-8-20 22:19 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
jaxxcyh 发表于 2024-8-10 13:34
你原来写的声明,只能在32位系统上使用。如果要在64位系统上使用,就要在每个 Declare 单词的后面添加一个 ...

您好,我加了ptrsafe后还是不能用,把long改为longlong也不行

TA的精华主题

TA的得分主题

发表于 2024-8-24 10:07 | 显示全部楼层
1076571536 发表于 2024-8-20 22:19
您好,我加了ptrsafe后还是不能用,把long改为longlong也不行

long不要改
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-11-18 16:28 , Processed in 0.032394 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表