1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Private Declare Function GetCurrentVbaProject Lib "vba332.dll" Alias "EbGetExecutingProj" (hProject As Long) As Long
Private Declare Function GetFuncID Lib "vba332.dll" Alias "TipGetFunctionId" (ByVal hProject As Long, ByVal strFunctionName As String, ByRef strFunctionID As String) As Long
Private Declare Function GetAddr Lib "vba332.dll" Alias "TipGetLpfnOfFunctionId" (ByVal hProject As Long, ByVal strFunctionID As String, ByRef lpfn As Long) As Long
Private Sub UserForm_Activate()
If Val(Application.Version) < 9 Then
SetTimer ghwnd, 0, 1, AddressOf97("GetPressedKey")
Else
SetTimer ghwnd, 0, 1, AddressOf GetPressedKey
End If
End Sub
Private Sub UserForm_Deactivate()
KillTimer ghwnd, 0
End Sub
Function AddressOf97(sFunctionName As String) As Long
Dim lResult As Long, lCurrentVBProject As Long, sFunctionID As String, lAddressOfFunction As Long, sFunctionUniCode As String
sFunctionUniCode = StrConv(sFunctionName, vbUnicode)
If GetCurrentVbaProject(lCurrentVBProject) <> 0 Then
lResult = GetFuncID(lCurrentVBProject, sFunctionUniCode, sFunctionID)
If lResult = 0 Then
lResult = GetAddr(lCurrentVBProject, sFunctionID, lAddressOfFunction)
If lResult = 0 Then AddressOf97 = lAddressOfFunction
End If
End If
End Function |
Partager