ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MsgBox with Timer (https://www.excelbanter.com/excel-programming/334279-msgbox-timer.html)

CarlosAntenna

MsgBox with Timer
 
Is it possible to display a MsgBox for 5 seconds and then make it disappear
without clicking the OK button? I looked at help under MsgBox but did not
see such an option. Is there some other way to achieve the same result?

--Carlos



Chip Pearson

MsgBox with Timer
 
Carlos,

In VBA, go to the Tools menu, choose References, and scroll down
to "Windows Script Host Object Model". Check this item in the
list. Then, use code like

Dim SH As IWshRuntimeLibrary.WshShell
Dim Res As Long
Set SH = New IWshRuntimeLibrary.WshShell
Res = SH.Popup(Text:="Click Me", secondstowait:=5, _
Title:="Hello, World", Type:=vbOKOnly)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"CarlosAntenna" wrote in message
...
Is it possible to display a MsgBox for 5 seconds and then make
it disappear
without clicking the OK button? I looked at help under MsgBox
but did not
see such an option. Is there some other way to achieve the
same result?

--Carlos





bigwheel

MsgBox with Timer
 
You could make your msgbox with a user form and have the form run the
following when it activates

Private Sub UserForm_Activate()

Application.OnTime Now + TimeValue("00:00:10"), "CloseForm"

End Sub

The "CloseForm" is a macro which closes the user form :-

Public Sub CloseForm()
Unload userform1
End Sub


"CarlosAntenna" wrote:

Is it possible to display a MsgBox for 5 seconds and then make it disappear
without clicking the OK button? I looked at help under MsgBox but did not
see such an option. Is there some other way to achieve the same result?

--Carlos




CarlosAntenna

MsgBox with Timer
 
Chip, You're a genius.
It works like a charm. You even included the OK button for users who are
too impatient to wait 5 seconds.
Thanks for the rapid response.

-- Carlos

"Chip Pearson" wrote in message
...
Carlos,

In VBA, go to the Tools menu, choose References, and scroll down
to "Windows Script Host Object Model". Check this item in the
list. Then, use code like

Dim SH As IWshRuntimeLibrary.WshShell
Dim Res As Long
Set SH = New IWshRuntimeLibrary.WshShell
Res = SH.Popup(Text:="Click Me", secondstowait:=5, _
Title:="Hello, World", Type:=vbOKOnly)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"CarlosAntenna" wrote in message
...
Is it possible to display a MsgBox for 5 seconds and then make
it disappear
without clicking the OK button? I looked at help under MsgBox
but did not
see such an option. Is there some other way to achieve the
same result?

--Carlos







CarlosAntenna

MsgBox with Timer
 
Thanks Big. I have not tried your solution because I already got it working
with Chip's method. Yours looks like exactly the kind of work-around I was
looking for.

Thanks,
--Carlos

"bigwheel" wrote in message
...
You could make your msgbox with a user form and have the form run the
following when it activates

Private Sub UserForm_Activate()

Application.OnTime Now + TimeValue("00:00:10"), "CloseForm"

End Sub

The "CloseForm" is a macro which closes the user form :-

Public Sub CloseForm()
Unload userform1
End Sub


"CarlosAntenna" wrote:

Is it possible to display a MsgBox for 5 seconds and then make it

disappear
without clicking the OK button? I looked at help under MsgBox but did

not
see such an option. Is there some other way to achieve the same result?

--Carlos







All times are GMT +1. The time now is 05:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com