Excel VBA - 两个具有相同标题的 IE 弹出窗口
Excel VBA - Two IE popups with same title
我正在编写一个 VBA IE 自动化程序。应用程序正在寻找特定的票号并尝试将其分配给用户。单击网页上的按钮后,在某些情况下,可能会 return 最多两个警报,它们都具有相同的 window 标题(“来自网页的消息”),需要按“确定”按钮。
我能够捕捉到第一个弹出窗口,但无法处理第二个。我认为处理此问题的最佳方法是阅读这些弹出窗口中的消息,但我不知道该怎么做。似乎两个 wscripts 都在捕获第一个弹出窗口,并且无法检测到第二个弹出窗口。你能帮忙吗?
我试过以下方法,但没有成功:
'' If ticket was found and is not assigned to any user, run script to handle popup
If sBut(currentPos + 11).innerHTML <> currentUser Then
pid = Shell("wscript.exe ""pathToScript\msgClick.vbs""")
End If
pid2 = Shell("wscript.exe ""pathToScript\itemClaimed.vbs""")
zBut = sBut(currentPos + 13).getElementsByTagName("input")
zBut.Click
单击 zBut 并显示两个 popus 后,脚本仅处理第一个,而第二个保持不变。
下面是 msgClick.vbs 的代码(和 itemClaimed.vbs,两者相同 - 我认为 运行 两个单独的文件可能会有帮助)
Set wshShell = CreateObject("WScript.Shell")
Do
windowLookUp = wshShell.AppActivate("Message from webpage")
Loop Until windowLookUp = True
WScript.sleep 500
windowLookUp = wshShell.AppActivate("Message from webpage")
If windowLookUp = True then
windowLookUp = wshShell.AppActivate("Message from webpage")
WScript.Sleep 10
wshShell.SendKeys "{enter}"
end if
傻我。
代替 运行 来自 VBA 的两个脚本,一个可以从 VBA 启动,另一个在第一个脚本执行后立即启动。很有魅力。
Set wshShell = CreateObject("WScript.Shell")
Do
windowLookUp = wshShell.AppActivate("Message from webpage")
Loop Until windowLookUp = True
WScript.sleep 500
windowLookUp = wshShell.AppActivate("Message from webpage")
If windowLookUp = True then
windowLookUp = wshShell.AppActivate("Message from webpage")
WScript.Sleep 10
wshShell.SendKeys "{enter}"
dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run "pthToScript\itemClaimed.vbs"
Set objShell = Nothing
end if
我正在编写一个 VBA IE 自动化程序。应用程序正在寻找特定的票号并尝试将其分配给用户。单击网页上的按钮后,在某些情况下,可能会 return 最多两个警报,它们都具有相同的 window 标题(“来自网页的消息”),需要按“确定”按钮。
我能够捕捉到第一个弹出窗口,但无法处理第二个。我认为处理此问题的最佳方法是阅读这些弹出窗口中的消息,但我不知道该怎么做。似乎两个 wscripts 都在捕获第一个弹出窗口,并且无法检测到第二个弹出窗口。你能帮忙吗?
我试过以下方法,但没有成功:
'' If ticket was found and is not assigned to any user, run script to handle popup
If sBut(currentPos + 11).innerHTML <> currentUser Then
pid = Shell("wscript.exe ""pathToScript\msgClick.vbs""")
End If
pid2 = Shell("wscript.exe ""pathToScript\itemClaimed.vbs""")
zBut = sBut(currentPos + 13).getElementsByTagName("input")
zBut.Click
单击 zBut 并显示两个 popus 后,脚本仅处理第一个,而第二个保持不变。
下面是 msgClick.vbs 的代码(和 itemClaimed.vbs,两者相同 - 我认为 运行 两个单独的文件可能会有帮助)
Set wshShell = CreateObject("WScript.Shell")
Do
windowLookUp = wshShell.AppActivate("Message from webpage")
Loop Until windowLookUp = True
WScript.sleep 500
windowLookUp = wshShell.AppActivate("Message from webpage")
If windowLookUp = True then
windowLookUp = wshShell.AppActivate("Message from webpage")
WScript.Sleep 10
wshShell.SendKeys "{enter}"
end if
傻我。 代替 运行 来自 VBA 的两个脚本,一个可以从 VBA 启动,另一个在第一个脚本执行后立即启动。很有魅力。
Set wshShell = CreateObject("WScript.Shell")
Do
windowLookUp = wshShell.AppActivate("Message from webpage")
Loop Until windowLookUp = True
WScript.sleep 500
windowLookUp = wshShell.AppActivate("Message from webpage")
If windowLookUp = True then
windowLookUp = wshShell.AppActivate("Message from webpage")
WScript.Sleep 10
wshShell.SendKeys "{enter}"
dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run "pthToScript\itemClaimed.vbs"
Set objShell = Nothing
end if