• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Automatically close the Msg box button

webmax

Member
Hi,

when i run the below macro it open the msg box as Hi and if i click the ok or enter button the msg box button disappears. i want a macro code to show Msg Box Hi for a two seconds and it would automatically close the Msg Box without Entering Ok or Enter button.

sub test()
Msgbox "Hi"
end sub
 
This functionality isn't available in the standard VBA messagebox. However, it can be achieved by using Shell object. Have you searched for this?
 
If you go to Visual Basic Editor | Tools | References then you should be able to locate the following reference:
Windows Script Host Object Model

Try the following code if you want an example of it.
Code:
Option Explicit
Public Sub CloseMessageBoxAfterInterval()
Const intSecondsToWait As Integer = 2
Dim wScript As Object: Set wScript = CreateObject("WScript.Shell")
wScript.Popup "Hi", intSecondsToWait, "TestMessage", vbOKOnly
End Sub
 
Back
Top