'** Déclaration API pour reproduire fonction AddressOf 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
Public Function fAddressOf(strFuncName As String) As Long
Dim hProject As Long Dim lngResult As Long Dim strID As String Dim lpfn As Long Dim strFuncNameUnicode As String Const NO_ERROR = 0 strFuncNameUnicode = StrConv(strFuncName, vbUnicode) Call GetCurrentVbaProject(hProject) If hProject <> 0 Then lngResult = GetFuncID( _ hProject, strFuncNameUnicode, strID) If lngResult = NO_ERROR Then lngResult = GetAddr(hProject, strID, lpfn) If lngResult = NO_ERROR Then fAddressOf = lpfn End If End If End If
End Function |