4

I am using VBScript to code some automation on excel. I have a MsgBox() within the code, and am looking for a way to close the pop-up window created by MsgBox() automatically without human intervention. Program execution would continue from there.

Xearinox
  • 3,224
  • 2
  • 24
  • 38
Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317
  • Did you change your name again Tukai? OMG! Well what you need can be done! ;) It's called a **`MSGBOX timer which gets triggered after being idle....`** – bonCodigo Dec 31 '12 at 18:57
  • @bonCodigo But how to do that? – Arup Rakshit Dec 31 '12 at 19:06
  • Here's a very similar question I answered yesterday http://stackoverflow.com/questions/14095982/side-step-application-msgbox-in-vba-excel/14096445#14096445 – Daniel Dec 31 '12 at 20:24

2 Answers2

6

The pure VBScript solution is the .PopUp method.

Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96
4

My comment has provided you tips to search and find out feasible answers. However to save your time, here is some insights.

  • This post shows how you may manupulate MSGBOX in VB.

  • Here is the best possible way anyone could think of in terms of VBA.

    1. Create a form
    2. Use it as a MSGBOX
    3. Add a timer
    4. Given an elapsed time (idle) close the form.

--

  • Another method Reference. This uses a Pop-Up box as the MSGBOX.

Code:

Sub Test1()
 Dim AckTime As Integer, InfoBox As Object

 Set InfoBox = CreateObject("WScript.Shell")
 AckTime = 3
 Select Case InfoBox.Popup("Click OK or do nothing within 3 seconds.", _
 AckTime, "This is your Message Box", 0)

 Case 1, -1
  Exit Sub
 End Select
End Sub
bonCodigo
  • 14,268
  • 1
  • 48
  • 91