ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatically close a message box (https://www.excelbanter.com/excel-programming/376375-automatically-close-message-box.html)

Ed

Automatically close a message box
 
I need to have a message box (vbokonly) close automatically if it has been
open for longer than 10 seconds.

thanks

bobbo

Automatically close a message box
 
I think all code execution stops while a message box or input box is
displayed. You could make your own Userform to look like a Msgbox and
use the ontime method to close it after a period of time.

ed wrote:
I need to have a message box (vbokonly) close automatically if it has been
open for longer than 10 seconds.

thanks



Jim Thomlinson

Automatically close a message box
 
Here is some code for a timed message box...

'***requires reference to "Windows Script Host Object Model"
Public Sub MessageTest()
Dim SH As IWshRuntimeLibrary.WshShell
Dim Res As Long

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

End Sub
--
HTH...

Jim Thomlinson


"ed" wrote:

I need to have a message box (vbokonly) close automatically if it has been
open for longer than 10 seconds.

thanks


Toby Erkson

Automatically close a message box
 
Nice Jim!

"Jim Thomlinson" wrote in message
...
Here is some code for a timed message box...

'***requires reference to "Windows Script Host Object Model"
Public Sub MessageTest()
Dim SH As IWshRuntimeLibrary.WshShell
Dim Res As Long

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

End Sub

....




All times are GMT +1. The time now is 02:58 AM.

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