I am running code to show a windows pop up which times out after a couple of seconds. The code works fine, but I need it to run correctly when a userform is displayed. The userform is not modal. However, the pop up opens as it should, but does not self close.
Public RunWhen As Double
Public Const cRunIntervalSeconds = 25 ' two minutes
Public Const cRunWhat = "MessageBoxTimer"
Sub MessageBoxTimer()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=False
Dim AckTime As Integer, InfoBox As Object
Set InfoBox = CreateObject("WScript.Shell")
AckTime = 2
Select Case InfoBox.Popup("Click OK (this window closes automatically after 2 seconds).", AckTime, "This is your Message Box", 0)
Case 1, -1
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=True
Exit Sub
End Select
End Sub
I have also tested the code with a completely blank userform, again with show modal set to false and have the same problem. Again, the pop up times out as it should if the userorm is NOT loaded.