Public Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA" (ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, Arguments As Long) As Long

Public Function LastSystemError() As String

Const FORMAT_MESSAGE_FORM_SYSTEM = &H1000

Dim sError As String * 500
Dim lErrMsg As Long

lErrMsg = FormatMessage(format_message_from_system, ByVal 0&, Err.LastDllError, sError, Len(sError), 0) 'I'm sure there is something missing

LastSystemError = Trim$(sError)

End Function