我正在尝试生成一个弹出窗口,并在给定的WaitTime
秒后关闭。
我尝试应用“VBA Excel宏消息框自动关闭”中的方法; 我的代码如下:
Sub TestSubroutine()
Dim TemporalBox As Integer
Dim WaitTime As Integer
Dim WScriptShell As Object
Set WScriptShell = CreateObject("WScript.Shell")
WaitTime = 1
TemporalBox = WScriptShell.Popup("The message box will close in 1 second.", _
WaitTime, "File processed")
End Sub
弹出窗口已经显示,但是它在一秒钟后没有关闭。
编辑 #1
根据@Skip Intro的评论,我已经更新了代码:
Sub TestSubroutine()
Dim WaitTime As Integer
WaitTime = 1
CreateObject("WScript.Shell").Popup "The message box will close in 1 second.", _
WaitTime, "File processed"
End Sub
然而,这并没有解决最初的问题,弹出窗口在1秒后仍未关闭。
编辑 #2
这是@Glitch_Doctor建议的代码,然而它仍然无法工作:
Sub TestSubroutine()
Dim TemporalBox As Integer
Dim WaitTime As Integer
Dim WScriptShell As Object
Dim test
Set WScriptShell = CreateObject("WScript.Shell")
WaitTime = 1
Select Case TemporalBox = WScriptShell.Popup("The message box will close in 1 second.", _
WaitTime, "File processed")
Case 1, -1
End Select
End Sub
CreateObject("WScript.Shell").popup "This is a message", 1, "This is a header", 0 + 64 '
。只有当你想要捕获响应时,它才会变得复杂,如果Wait
= 1 秒,我认为你不需要这样做。 - Skip IntroWindows 7
Excel 2010
- Skip Intro