0

I would like to login into a webpage, however I did not succeed and could not find any useful tutorial, description or advice. On this page: https://emir.palyazat.gov.hu/nd/eupalyazat/index.php?tip=100009&opid=9#login_jelzo I would like to choose from the list “GOP-2.1.3-11” (value: 1950), then another (former hidden) list will appear. From this list I have to choose GOP-2.1.3-11-2011-0085 (value: 74347). At the first step I got stuck with the code below:

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

I have to manage more accounts on that page and it would be very easy to login by clicking on a button .

References: Microsoft Internet Control, Microsoft HTML Object Library, Microsoft xml, v6.0, and Microsoft_Jscript.

Thanks for your help in advance and if you there is a comprehensive description on handling webpages in VBA please paste in it your answer too. Thank you very much.

1 Answers1

1

I had to use application.sendkeys, but at the end it was success:

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

However, I did not find any comprehensive description about IE and VBA. Would you please recommend one? THX

  • more info about sendkeys: https://stackoverflow.com/questions/11655591/ie-9-not-accepting-sendkeys – jsotola Aug 03 '17 at 02:16