XL VBA: message box to close after x seconds... not closing

2Took

Board Regular
Joined
Jun 13, 2022
Messages
203
Office Version
  1. 365
Platform
  1. Windows
Hi,

Below code supposed to close the box after 3 seconds... rarely does it work however.

Any way to fix or some other way to accomplish the reliable closing after preset time?


VBA Code:
Sub MessageBoxTimer()
    Dim AckTime As Integer, InfoBox As Object
    Set InfoBox = CreateObject("WScript.Shell")
    'Set the message box to close after x seconds
    AckTime = 3
    Select Case InfoBox.Popup("body text.", _
    AckTime, "header text", 0)
        Case 1, -1
            Exit Sub
    End Select
End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
That method is notoriously unreliable. I'd suggest making your own userform instead.
 
Upvote 0
That method is notoriously unreliable. I'd suggest making your own userform instead.
Is there a simple VBA way to create & display a simple userform, similar to MsgBox -- without having to create it manually?
 
Upvote 0
Not really, no.

You might want to search the forum and see if @Jaafar Tribak has previously posted something for this using API calls.
 
Upvote 0
Take a look here:

Or for a lighter alternative :
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top