OptionExplicitDimiCounterAsIntegerDimlngTimerIDAsLongDimBlnTimerAsBooleanDeclarePtrSafeFunctionSetTimerLib"user32"(ByValhwndAsLong, _ByValnIDEventAsLong, _ByValuElapseAsLong, _ByVallpTimerFuncAsLongPtr)AsLongDeclarePtrSafeFunctionKillTimerLib"user32"(ByValhwndAsLong, _ByValnDEventAsLong)AsL...
If you are using the 64-bit version of Microsoft Office, VBA function declarations are slightly different from those in the 32-bit version. In 64-bit versions, the declarations includePtrSafeafter theDeclarekeyword. For example: 32-bit version:Public Declare Function HypMenuVAbout Lib "HsAddin" ...
Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr Declare PtrSafe Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As LongPtr, ByVal lpClassName As String, ByVal nMaxCount As Long...
在 64 位 Office 中,这是一种错误情况,因为指针必须是 64 位。PtrSafe 限定符告知编译器 Declare 语句面向的是 64 位,这样语句在执行时就不会出现错误。不过,由于返回值尚未更新为 64 位数据类型,因此,截断返回值会导致返回不正确的值。 未修改的旧 VBA Declare 语句示例: VBA Declare Function GetActiveWindow...
64-bit Declare statement example: Declare PtrSafe Function GetActiveWindow Lib "User32" () As LongPtr ' Conditional Compilation Example #IfVba7Then' Code is running in 32-bit or 64-bit VBA7.#If Win64 Then ' Code is running in 64-bit VBA7. #Else' Code is not running in 64-bit VBA...
Private Declare PtrSafe Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) As Long Private Declare PtrSafe Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BrowseInfo) As Long Private Declare PtrSafe Function...
你可以试试 Declare 后面加上PtrSafe ,可以实现兼容例如 Private Declare Function WindowFromPoint Lib "...
32-bit的VBA程序,在64-bit系统上运行时,出现该编译错误。 环境:Office2010 Excel 64-bit, 64-bit Win7 OS 2.原因 原程序中,函数声明如下。该函数在32-bit系统中编译、运行没有问题。但是在64-bit系统中会出现编译错误。 Private Declare Function WideCharToMultiByte Lib "kernel32" _ ...
64-bit Declare statement example: Declare PtrSafe Function GetActiveWindow Lib "User32" () As LongPtr ' Conditional Compilation Example #IfVba7Then' Code is running in 32-bit or 64-bit VBA7.#If Win64 Then ' Code is running in 64-bit VBA7. #Else' Code is not running in 64-bit VBA...
智能的打开你目前所在窗口的属性 我们按照惯例先看一下项目的管理栏目 首先好的一点就是可以看出来项目...