新建模块,把以下全部代码复制粘贴到模块里面,保存模块,即可兼容64位access了
Option Compare Database
'API函数声明
#If VBA7 Then
Public Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As LongPtr) As LongPtr
Public Declare PtrSafe Function SetCursor Lib "user32" (ByVal hCursor As LongPtr) As LongPtr
Public Declare PtrSafe Function LoadCursorByNum Lib "user32" Alias "LoadCursorA" (ByVal hInstance As LongPtr, ByVal lpCursorName As LongPtr) As LongPtr
#Else
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As LongPtr) As LongPtr
Public Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
Public Declare Function LoadCursorByNum Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
#End If
Public Const IDC_HAND = 32649& '手形
Public Const IDC_APPSTARTING = 32650& '系统忙
Public Const IDC_ARROW = 32512& '常规箭头形
Public Const IDC_CROSS = 32515& '十字形
Public Const IDC_IBEAM = 32513& '文本插入
Public Const IDC_ICON = 32641& '使用指定光标文件
Public Const IDC_NO = 32648& '不可用
Public Const IDC_SIZE = 32640& '隐藏指针
Public Const IDC_SIZEALL = 32646& '选中并移动
Public Const IDC_SIZENESW = 32643& '左下角右上角大小调整
Public Const IDC_SIZENS = 32645& '上下调整
Public Const IDC_SIZENWSE = 32642& '左上角右下角大小调整
Public Const IDC_SIZEWE = 32644& '左右调整
Public Const IDC_UPARROW = 32516& '上箭头
Public Const IDC_WAIT = 32514& '沙漏
'改变光标指针调用示例: SetCursor LoadCursorByNum(0,32649)
' SetCursor LoadCursorByNum(0, IDC_HAND)
'ShellExecute函数二次封装,以简化使用
'输入参数File可以是文件名,网页地址或命令行
Public Function ShellEx(File As String)
ShellExecute hWndAccessApp, "Open", File, 0, 0, 1
End Function