在vbscript中自动关闭MsgBox? [英] Automatically close MsgBox in vbscript?

查看:59
本文介绍了在vbscript中自动关闭MsgBox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 VBScript 在 excel 上编写一些自动化代码.我在代码中有一个 MsgBox(),我正在寻找一种无需人工干预即可自动关闭由 MsgBox() 创建的弹出窗口的方法.程序执行将从那里继续.

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.

推荐答案

我的评论为您提供了搜索和找出可行答案的提示.但是,为了节省您的时间,这里有一些见解.

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

这是任何人都可以想到的 VBA 最佳方式.

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

  1. 创建表单
  2. 将其用作 MSGBOX
  3. 添加计时器
  4. 给定一段时间(空闲)关闭表单.

--

  • 另一种方法 参考.这使用 Pop-Up 框作为 MSGBOX.
  • Another method Reference. This uses a Pop-Up box as the MSGBOX.

代码:

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

这篇关于在vbscript中自动关闭MsgBox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆