How do I bring focus to a msgbox?

别等时光非礼了梦想. 提交于 2020-02-15 00:48:32

问题


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.

When I leave AppActivate("Checker") I get: Run-Time error '5': Invalid procedure call argument, help?


回答1:


Try this:

...
AppActivate ("Microsoft excel")
xreply = MsgBox("Is this page for women? Record:" & i, vbYesNo, "Checker")
...


来源:https://stackoverflow.com/questions/18832966/how-do-i-bring-focus-to-a-msgbox

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