2017-07-06 107 views
0

我想登錄到一個網頁,但是我沒有成功,也找不到任何有用的教程,描述或建議。本頁內容:https://emir.palyazat.gov.hu/nd/eupalyazat/index.php?tip=100009&opid=9#login_jelzo我想從列表「GOP-2.1.3-11」(值:1950)中選擇,然後會出現另一個(以前的隱藏)列表。從這個清單中我必須選擇GOP-2.1.3-11-2011-0085(價值:74347)。在第一步我被困下面的代碼:IE ans Excel VBA - 從下拉列表中選擇項目

Sub IEopen() 

Dim IE As New SHDocVw.InternetExplorer 
Dim HTMLDoc As MSHTML.HTMLDocument 
Dim HTMLInput As MSHTML.IHTMLElement 
Dim HTMLButtons As MSHTML.IHTMLElementCollection 
Dim HTMLButton As MSHTML.IHTMLElement 
Dim HTMLTable As MSHTML.IHTMLElement 
Dim HTMLTables As MSHTML.IHTMLElementCollection 
Dim HTMLRow As MSHTML.IHTMLElement 

IE.Visible = True 
IE.Navigate "https://emir.palyazat.gov.hu/nd/eupalyazat/index.php?tip=100009&opid=9#login_jelzo" 

Do While IE.ReadyState <> READYSTATE_COMPLETE 
Loop 

Set HTMLDoc = IE.Document 

Set HTMLRow = HTMLDoc.getElementById("id_paly_altip") 
HTMLRow.Value = "1950" 
End Sub 

我要管理該網頁上的多個賬戶,這將是很容易通過點擊一個按鈕來登錄。

參考文獻:Microsoft Internet Control,Microsoft HTML Object Library,Microsoft xml,v6.0和Microsoft_Jscript。

感謝您的幫助,如果您有關於在VBA中處理網頁的綜合描述,請粘貼您的答案。非常感謝你。

+0

查看這些對象'MSHTML.HTMLInputElement' 'MSHTML.HTMLSelectElement' –

+0

我已將do while while循環更改爲Application.wait。現在我可以選擇「id_paly_altip」的值,但是下一個列表(palyazat_szama)不會出現。爲什麼? –

+0

我不得不使用application.sendkeys,但最終它成功 –

回答

0

我不得不使用application.sendkeys,但最終它是成功的:

Set HTMLRow = HTMLDoc.getElementById("id_paly_altip") 
HTMLRow.Value = "XXXXXXXXXXX" 
Application.SendKeys ("{up}") 
Application.Wait (Now + TimeValue("0:00:01")) 
Application.SendKeys ("{down}") 
Application.Wait (Now + TimeValue("0:00:01")) 

Application.SendKeys ("{tab}") 

Set HTMLRow = HTMLDoc.getElementById("palyazat_szama") 
HTMLRow.Value = "XXXXXXXXXXXXX" 
Application.SendKeys ("{up}") 
Application.Wait (Now + TimeValue("0:00:01")) 
Application.SendKeys ("{down}") 
Application.Wait (Now + TimeValue("0:00:01")) 

Set HTMLRow = HTMLDoc.getElementById("lb_felhasznalo") 
HTMLRow.Value = "XXXXXXXXXXXXXXXX" 

Application.SendKeys ("{tab 2}") 
Application.SendKeys ("XXXXXXXXXXXXXXXXXXXXXXX") 

Application.Wait (Now + TimeValue("0:00:01")) 

Set HTMLButton = HTMLDoc.getElementById("login_submit") 
HTMLButton.disabled = "" 
HTMLButton.Click 

Application.SendKeys "{NUMLOCK}%s" 

End Sub 

但是,我沒有找到有關IE和VBA任何全面的描述。你能推薦一個嗎? THX

+0

有關sendkeys的更多信息:https://stackoverflow.com/questions/11655591/ie-9-not-accepting-sendkeys – jsotola

相關問題