vba 如何将焦点放在 msgbox 上?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18832966/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 23:21:13 来源:igfitidea点击:
How do I bring focus to a msgbox?
提问by Michaeljwjr
Private Sub CommandButton1_Click()
Dim i As Long
Dim xreply As Integer
Dim names As Long
Dim IE As Object
i = ActiveSheet.Range("D1").Value
While Not IsEmpty(ActiveSheet.Range("A" & i).Value)
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "WEBSITENAME" & ActiveSheet.Range("A" & i).Value
'wait for webpage to load
Do
DoEvents
Loop Until IE.READYSTATE = 4
'pagedown to the info
Application.SendKeys "{PGDN}", True
Application.SendKeys "{PGDN}", True
xreply = MsgBox("Is this page for women? Record:" & i, vbYesNo, "Checker")
Application.Visible = True
AppActivate ("Checker")
If xreply = vbYes Then
ActiveSheet.Range("B" & i).Value = "Yes"
Else
ActiveSheet.Range("B" & i).Value = "No"
End If
'quit IE
IE.Quit
i = i + 1
ActiveSheet.Range("D1").Value = i
Wend
End Sub
Above is my code. I am trying to bring the msgbox to the front, yet I can not get AppActivate to do so.
以上是我的代码。我试图将 msgbox 放在前面,但我无法让 AppActivate 这样做。
When I leave AppActivate("Checker") I get: Run-Time error '5': Invalid procedure call argument, help?
当我离开 AppActivate("Checker") 时,我得到:运行时错误 '5':过程调用参数无效,有帮助吗?
回答by Dmitry Merkis
Try this:
尝试这个:
...
AppActivate ("Microsoft excel")
xreply = MsgBox("Is this page for women? Record:" & i, vbYesNo, "Checker")
...