excelvbadllwinhttp

How to declare SYSTEMTIME structure in VBA


I create a short snippet to measure elapsed time between two defined points during a VBA macro. But to get the time in SYSTEMTIME structure (must use it) format i can't define, because an Bad DLL calling convention (Error 49) error is thrown. I know that SYSTEMTIME structure is 8 Integer numbers which are passed through the function.

The declaration of the function

Private Declare Function WinHttpTimeToSystemTime Lib "winhttp.dll" (Byval time as String, several attempts)

These attempts:

ByVal systime as String
ByVal systime as Integer
ByVal systime as Long (only for sure)
ByRef systime() as Integer (VBA let only ByRef access)
ByRef systime as userdef (user-defined type with 8 integer variables)

All resulted the above error.

Is there a solution?


Solution

  • Based on the comments I recheck the declaration and the problem was that the return value of the function was missing. Added As Boolean and the function was executed.