Automatically close MsgBox in vbscript?

巧了我就是萌 提交于 2019-12-30 07:27:31

问题


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.


回答1:


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



回答2:


The pure VBScript solution is the .PopUp method.



来源:https://stackoverflow.com/questions/14105157/automatically-close-msgbox-in-vbscript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!