处理弹出当与IE浏览器浏览 [英] Handle Pop-Up While Navigating with IE
问题描述
我有一个Excel VBA宏
- 打开IE浏览器,
- 导航到Medicare网页,
- 登录我,
- 与那些在网站上列出的索赔比较已经在工作簿
- 提醒我任何差异
这期间我有一个问题的登录的步骤,所以我转载低于code的那部分。一样执行。点击
线不久的弹出窗口出现,要求用户点击才能继续在<大骨节病>确定骨节病>按钮。宏的执行被暂停,直到我手动点击弹出的<大骨节病>确定骨节病>按钮。
http://www.mymedicare.gov 的网页背后的源代码code的相关信息到弹出,但我一直无法弄清楚如何使用它,这样我可以编程方式单击弹出<大骨节病>确定骨节病>按钮。
在搞清楚如何编程方式单击弹出的<大骨节病>确定骨节病>按钮会大大AP preciated。
方面任何帮助
请注意:对于这个问题的目的,任何用户ID和密码都可以使用。如果您处理弹出,你会被传递到一个页面,说像不正确的用户ID /密码。
这将表明您已经成功地处理弹出。
块引用>子Medicare_Claims()'
更新状态栏
Application.StatusBar =运行医疗保险索赔子程序打开MyMedicare网页
即设置=的CreateObject(InternetExplorer.Application)
与IE浏览器
。可见=真
.Navigatehttps://www.mymedicare.gov/
结束与循环,直至页面完全加载
做,直到ie.ReadyState = 4,不ie.Busy
的DoEvents
循环' 登录
ie.Document.all.Item(ctl00_ContentPlaceHolder1_ctl00_HomePage_SWEUserName)。值=ABCDE
ie.Document.all.Item(ctl00_ContentPlaceHolder1_ctl00_HomePage_SWEPassword)。值=12345
ie.Document.getElementById(ctl00_ContentPlaceHolder1_ctl00_HomePage_SignIn)。点击循环,直至页面完全加载
做,直到ie.ReadyState = 4,不ie.Busy
的DoEvents
循环 Application.Wait(现在+ TIMEVALUE(零点零零分15秒))再导航到搜索索赔网页
ie.Navigatehttps://www.mymedicare.gov/searchclaims.aspx
解决方案在任何情况下,再次通过这种方式,这里是由Tim威廉姆斯提供的解决方案:
'登录ie.Document.all.Itemctl00_ContentPlaceHolder1_ctl00_HomePage_SWEUserName)。值=ABCDEie.Document.all.Item(ctl00_ContentPlaceHolder1_ctl00_HomePage_SWEPassword)。值=12345昏暗f,按字符串F =功能(签到){document.getElementById'ctl00_ContentPlaceHolder1_ctl00_HomePage_Agree。)值='真';}ie.Document.parentWindow.execScriptwindow.ConfirmationPopup =与&amp;楼的JScriptie.Document.getElementById(ctl00_ContentPlaceHolder1_ctl00_HomePage_SignIn)。点击
I have an Excel VBA macro that
- opens IE,
- navigates to the Medicare website,
- logs me in,
- compares the claims listed on the website with those already in the workbook
- alerts me to any differences
It is during the log-in step that I have a problem, so I've reproduced that portion of the code below. As soon as the
.click
line is executed a pop-up window appears asking the user to click the OK button in order to proceed. Macro execution is suspended until I manually click the OK button on the pop-up.The source code behind the http://www.mymedicare.gov web page has information relative to the pop-up, but I haven't been able to figure out how to use it so that I can programmatically click the pop-up OK button.
Any help in terms of figuring out how to programmatically click the pop-up's OK button would be much appreciated.
note: For the purpose of this question, any user id and password can be used. If you handle the pop-up you'll be passed to a page that says something like incorrect user id / password.
That will indicate that you've been successful in handling the pop-up.
Sub Medicare_Claims()' ' Update the status bar Application.StatusBar = "Running the Medicare Claims subroutine" ' Open the "MyMedicare web page Set ie = CreateObject("InternetExplorer.Application") With ie .Visible = True .Navigate "https://www.mymedicare.gov/" End With ' Loop until the page is fully loaded Do Until ie.ReadyState = 4 And Not ie.Busy DoEvents Loop ' Log-in ie.Document.all.Item("ctl00_ContentPlaceHolder1_ctl00_HomePage_SWEUserName").Value = "abcde" ie.Document.all.Item("ctl00_ContentPlaceHolder1_ctl00_HomePage_SWEPassword").Value = "12345" ie.Document.getElementById("ctl00_ContentPlaceHolder1_ctl00_HomePage_SignIn").Click ' Loop until the page is fully loaded Do Until ie.ReadyState = 4 And Not ie.Busy DoEvents Loop Application.Wait (Now + TimeValue("0:00:15")) ' Navigate further to the Search Claims" web page ie.Navigate "https://www.mymedicare.gov/searchclaims.aspx"
解决方案In case anyone passes this way again, here is the solution provided by Tim Williams:
'Log-in ie.Document.all.Item"ctl00_ContentPlaceHolder1_ctl00_HomePage_SWEUserName").Value= "abcde" ie.Document.all.Item("ctl00_ContentPlaceHolder1_ctl00_HomePage_SWEPassword").Value = "12345" Dim f As String f = "function(SignIn){document.getElementById'ctl00_ContentPlaceHolder1_ctl00_HomePage_Agree').value = 'True';}" ie.Document.parentWindow.execScript "window.ConfirmationPopup = " & f, "jscript" ie.Document.getElementById("ctl00_ContentPlaceHolder1_ctl00_HomePage_SignIn").Click
这篇关于处理弹出当与IE浏览器浏览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!