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
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
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
I am trying it too in Excel 365 but will not auto-close 🙂
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.
Thank you Tom, closing everything worked for me. You saved me a real headache. Thank you.
Cool – – thanks for the follow-up, Elizabeth.
I am trying it too in Excel 365 but will not auto-close