2016-06-23 7 views
0

でナビゲートしながら、私は、Excel VBAを持つマクロハンドルウェブサイトのポップアップIE

  1. はIE、メディケアのウェブサイトへ
  2. ナビゲート、
  3. ログ私を、
  4. は、請求項を比較を開くことワークブックで、すでにそれらをウェブサイトに掲載され
  5. は、任意の違いを私に警告し

ログイン中に問題が発生しているので、私は以下のコードの部分を再現しました。 .click行が実行されるとすぐに、ユーザにOKボタンをクリックするように求めるポップアップウィンドウが表示されます。マクロ実行は、ポップアップでOKボタンを手動でクリックするまで中断されます。

http://www.mymedicare.gov Webページの後ろのソースコードは、ポップアップに関連する情報を持っているが、私はプログラム的にポップアップOKボタンをクリックすることができるようにそれを使用する方法を見つけ出すことができませんでした。

数年前、私はthis questionを投稿し、Tim Williamsはポップアップウィンドウの背後にあるjavascriptとのやり取りに基づいて優れたsolutionを提供しました。メディケアはWebページの背後にあるコードを変更し、Timのソリューションはもはやポップアップウィンドウを処理しません。私はTimのテーマについて多くのバリエーションを試しましたが、解決策を見つけられませんでした。

プログラムでポップアップのOKボタンをクリックする方法を理解する上で助けがあれば幸いです。

注:この質問の目的のために、任意のユーザーIDとパスワードを使用できます(下記のコードではabcdeと12345を使いました)。ポップアップを処理すると、間違ったユーザーID /パスワードなどのページに渡されます。これはあなたがポップアップの処理に成功したことを示します。

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" 

答えて

1

これは私

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 
    Dim doc As Object 

    Set doc = ie.Document 

    doc.getElementById("ctl00_ContentPlaceHolder1_ctl00_HomePage_SWEUserName").Value = "abcde" 
    doc.getElementById("ctl00_ContentPlaceHolder1_ctl00_HomePage_SWEPassword").Value = "12345" 
    doc.getElementById("ctl00_ContentPlaceHolder1_ctl00_HomePage_Agree").Value = "True" 

    doc.parentWindow.execScript "window.ConfirmationPopup = function(){null;}", "jscript" 

    doc.getElementById("ctl00_ContentPlaceHolder1_ctl00_HomePage_SignIn").Click 

End Sub 
のために働いていました
関連する問題