How to close currently open MsgBox using VBA?

Is it possible to close open MsgBox using any code in the application of the VBA access form?

+3
source share
9 answers

Mark Randy Birch's answer to this thread at microsoft.public.vb.general.discussion

He recommends creating a function in the .bas MsgBox file. This will cause VB to call your function, not the built-in one.

Then you create your own MsgBox form and create a timer to close the form after a certain period of time. It provides links showing how to do this.

MsgBox, .

. , , - .

+6

MsgBoxes , . , MsgBox, , , .

+2

, , MsgBox - , , , , . ?

+1

MarkJ, , Access ( VBA.MsgBox, )?

, "dataview" " 1 ..." ( ). , ? , ...

+1

: Windows Scripting Shell, "Popup" - Message, VBA MsgBox(), "SecondsToWait", , .

   CreateObject ( "Scripting.WsShell" )   .Popup ",     5 ", 5, Application.Name  ": test", vbInformation + vbOkCancel
 

"", : vbOkCancel, vbYesNoCancel vbRetryCancel.

, msgBox(), : , , "SecondsToWait" - - , , .

"" Message Box Timer() API - MsgBox, , , , VBA, fooobar.com/questions/1329907/....

, , , .

+1

, Access MsgBox , (, , ) Arvin Meyer Custom MessageBox Creator ( this ).

0

; "SendKeys" (. http://msdn.microsoft.com/en-us/library/8c6yea83%28VS.85%29.aspx). MsgBox , . , , ( ) whshell, , SendKeys. , , (). , / , , , VBA.

0

. , , - .

sendkeys win API.

0

Win32, . , PopUpBox . 1/2 , 2 = 1 . . . , , , .

:

Declare Function MessageBoxTimeout Lib "user32.dll" Alias "MessageBoxTimeoutA" ( _
    ByVal hwnd As Long, _
    ByVal lpText As String, _
    ByVal lpCaption As String, _
    ByVal uType As Long, _
    ByVal wLanguageID As Long, _
    ByVal lngMilliseconds As Long) As Long

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long

Public Function PopUpBox(Optional stMessage As String _
        = "Yes or No? leaving this window for 1 min is the same as clicking Yes.", _
        Optional stTitle As String = "PopUp Window", _
        Optional HalfSecTimer As Long = 120, Optional lgVBmsgType As Long = vbYesNo) As Long

    Dim RetVal As Long

    HalfSecTimer = HalfSecTimer * 500
    RetVal = MessageBoxTimeout(FindWindow(vbNullString, Title), stMessage, stTitle, lgVBmsgType, _ 
        0, HalfSecTimer)

    PopUpBox = RetVal
End Function

Call function code
Examples: actual code from my database

PopUpBox "Re-Linking and Closing dB", "Closing dB", 3, vbOKOnly
intAnswer = PopUpBox("Software Lock Down Active?", "Security", 10, vbYesNo)
0
source

Source: https://habr.com/ru/post/1712797/


All Articles