Tom’s Tutorials for Excel: Automatically Dismiss a Message Box

Tom’s Tutorials for Excel: Automatically Dismiss a Message Box

This example shows how to automatically dismiss a message box after a specified period of time. The message box is shown, then automatically dismisses itself after 10 seconds.

Here’s the example macro:

Sub MessageBoxTimer()
    Dim AckTime As Integer, InfoBox As Object
    Set InfoBox = CreateObject("WScript.Shell")
    'Set the message box to close after 10 seconds
    AckTime = 10
    Select Case InfoBox.Popup("Click OK (this window closes automatically after 10 seconds).", _
    AckTime, "This is your Message Box", 0)
        Case 1, -1
            Exit Sub
    End Select
End Sub


Share Button
Posted in Tom's Tutorials for Excel
Tags: , , , , , , , , , , ,
7 comments on “Tom’s Tutorials for Excel: Automatically Dismiss a Message Box
  1. Colin Delane says:

    Hi Tom
    I found your code for dismissing a message box (a great idea and a useful addition to my VBA toolbox, thanks), and added it to a project. It worked for a few times and then stopped (box displays but doesn’t timeout??) – and I can’t work out why!

    I tried a reset of the event handler (Application.EnableEvents = True) but to no avail.

    Any thoughts/suggestions?

    Many thanks
    Col Delane
    Perth, Western Australia

  2. Colin Delane says:

    Hi Tom
    (Take two – error in my email address in 1st post)
    I found your code for dismissing a message box (a great idea and a useful addition to my VBA toolbox, thanks), and added it to a project. It worked for a few times and then stopped (box displays but doesn’t timeout??) – and I can’t work out why!

    I tried a reset of the event handler (Application.EnableEvents = True) but to no avail.

    Any thoughts/suggestions?

    Many thanks
    Col Delane
    Perth, Western Australia

  3. Chano says:

    I am trying it too in Excel 365 but will not auto-close 🙂

    • Tom Urtis says:

      I have heard and seen this myself and here is what I do, so please try this and see if it works for you. Post back either way.

      Save and close your workbook. Totally quit Excel, not just closing the workbooks but quitting and ending end exiting Excel altogether. Now open that workbook and try again It works for me. But if you follow these steps and it does not work for you I would like to know please. Thanks.

  4. Lars says:

    I am trying it too in Excel 365 but will not auto-close

Leave a Reply

Your email address will not be published. Required fields are marked *

*