#If VBA7 Then
Public Declare PtrSafe Function MessageBoxTimeoutW Lib "user32" (ByVal hWnd As LongPtr, _
ByVal lpText As String, ByVal lpCaption As String, _
ByVal uType As Long, ByVal wLanguageId As Integer, _
ByVal dwMilliseconds As Long) As Long
#Else
Public Declare Function MessageBoxTimeoutW Lib "user32" (ByVal hWnd As Long, _
ByVal lpText As String, ByVal lpCaption As String, _
ByVal uType As Long, ByVal wLanguageId As Integer, _
ByVal dwMilliseconds As Long) As Long
#End If
Function MsgBoxTimeout(ByVal message As String, ByVal timeout As Long, Optional ByVal Title As String = "Message", Optional ByVal flags As VbMsgBoxStyle = vbOKOnly) As VbMsgBoxResult
MsgBoxTimeout = MessageBoxTimeoutW(0, StrConv(message, vbUnicode), StrConv(Title, vbUnicode), flags, 0, timeout)
End Function