Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88854

Display popup for a time period in Excel

$
0
0

I am trying to generate in Excel VBA a popup that automatically closes after a given WaitTime in seconds. I have consulted the thread "VBA Excel macro message box auto close" as well as this and this links. I have tried to apply the method from the StackExchange thread cited; my code is the following:

Sub TestSubroutine()

Dim TemporalBox As Integer
Dim WaitTime As Integer
Dim WScriptShell As Object

Set WScriptShell = CreateObject("WScript.Shell")

WaitTime = 1
TemporalBox = WScriptShell.Popup("The message box will close in 1 second.", _
WaitTime, "File processed")

End Sub

However it does not seem to be working, the popup is displayed but it never closes after 1 second.

Does anybody spot what I am doing wrong?


Edit #1

Based on @Skip Intro comment, I have updated the code:

Sub TestSubroutine()

Dim WaitTime As Integer

WaitTime = 1
CreateObject("WScript.Shell").Popup "The message box will close in 1 second.", _
WaitTime, "File processed"

End Sub

However this does not solve the original issue, the popup does not close after 1 second.

Edit #2

This is the code suggested by @Glitch_Doctor, however it still doesn't work:

Sub TestSubroutine()

Dim TemporalBox As Integer
Dim WaitTime As Integer
Dim WScriptShell As Object
Dim test

Set WScriptShell = CreateObject("WScript.Shell")

WaitTime = 1
Select Case TemporalBox = WScriptShell.Popup("The message box will close in 1 second.", _
WaitTime, "File processed")
    Case 1, -1
End Select

End Sub

Viewing all articles
Browse latest Browse all 88854

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>