I read so many answers to my problem, but for some reason, if I try to "imitate" what I see, I am still not able to do what I need.
The problem is very simple: fill in the input field on the open IE page.
Result: the code loops on the line with getelementbyid , displaying a 424 runtime error (object required).
Private Sub AddInfoFromIntranet() Dim ie As Object Set ie = CreateObject("internetexplorer.application") Application.SendKeys "{ESC}" ' I need this to ignore a prompt With ie .Visible = True .navigate "{here goes the address of my website}" Do Until Not .Busy And .readyState = 4 DoEvents Loop .document.getelementbyid("Nachnamevalue").Value = "{here goes whar I want to insert}" End With Set ie = Nothing End Sub
Internet Explorer libraries were naturally imported (otherwise "internetexplorer.application" will not work.
I am sure that the field I want to fill out is called “Nachnamevalue”, as from what I learned this morning, looking around the internet.
The html code of my webpage (just an interesting snippet) looks like this:
<!DOCTYPE html> <html> <head> <title></title> <style> '{here there are info on the style, which i'm gonna ignore} </style> </head> <body bgcolor="#ffffcc"><table width="1000"><tbody><tr><td> <form name="Suchform" action="index.cfm" method="get" target="bottom_window"> Nachname: <select name="Nachnamepulldown" class="font09px" onchange="wait_and_search()"> <option value="BEGINS_WITH">beginnt mit <option value="EQUAL">ist <option value="CONTAINS">enthält </option></select> <input name="Nachnamevalue" onkeyup="wait_and_search()" type="text" size="8"> Abteilung: <select name="Abteilungpulldown" class="font09px" onchange="wait_and_search()"> <option value="BEGINS_WITH">beginnt mit <option value="EQUAL">ist <option value="CONTAINS">enthält </option></select> <input name="Abteilungvalue" onkeyup="wait_and_search()" type="text" size="3"> <input name="fuseaction" type="hidden" value="StdSearchResult"> <input type="submit" value="suchen"> <script language="JavaScript" type="text/JavaScript"> document.Suchform.Nachnamevalue.focus(); </script> </form> </td></tr></tbody></table></body> </html>
There is also (I don’t know if it can help) a “built-in” javascript that brings search results every time at least two characters are written in the “Nachnamevalue” input field.
What am I doing wrong?
EDIT: When I try to execute Sub step by step, I get the following:
Set Doc = ie.document
? doctor [HTMLDocument object] (on the watchlist, this is an object without any variables inside)
source share