这个问题是关于下面列出的最佳解决方法,或者您知道的另一个问题.
这是问题的背景,它来自这样的代码......
Set scriptshell = CreateObject("wscript.shell")
Const TIMEOUT_IN_SECS = 60
Select Case scriptshell.popup("Yes or No? leaving this window for 1 min is the same as clicking Yes.", TIMEOUT_IN_SECS, "popup window", vbYesNo + vbQuestion)
Case vbYes
Call MethodFoo
Case -1
Call MethodFoo
End Select
Run Code Online (Sandbox Code Playgroud)
这是一种显示带有VBA或VB6超时的消息框的简单方法.问题是特别是在Excel 2007中(显然有时也会出现在Internet Explorer中),弹出窗口将意外地不会超时,而是等待用户输入.这个问题很难调试,因为它偶尔会发生,我不知道重现问题的步骤.到目前为止,我认为它是Office模式对话框的一个问题,并且excel不能识别超时已过期.
请看这里...
http://social.technet.microsoft.com/Forums/en-US/ITCG/thread/251143a6-e4ea-4359-b821-34877ddf91fb/
我在此处列出了此问题的解决方法.
A.使用Win32 API调用
Declare Function MessageBoxTimeout Lib "user32.dll" Alias "MessageBoxTimeoutA" ( _
ByVal hwnd As Long, _
ByVal lpText As String, _
ByVal lpCaption As String, _
ByVal uType As Long, _ …Run Code Online (Sandbox Code Playgroud)