pressing a button in an ie page using vba
9,533
Just an FYI BruceWayne's suggesting worked for me but I just had to change (0)
to (1)
.
IE.document.getElementsByName("Action")(1).Click
Related videos on Youtube
Comments
-
Eric over 1 year
I've been trying to manipulate an internal website using vba but I have run into a problem. Currently, my script below opens the webpage and enters the values of cell a1 in sheet1 into the text box on the webpage. My problem is when I try to click on the search button I get the following message "run time error 438 Object doesn't support this property or method". I have tried a few different ways but none work. Also I have added the button properties when I inspect element. Thanks!
<input name="Action" onclick="this.disabled=true; this.form.submit();" type="submit" value="Search"> Sub autoIE() Dim IE As Object Set IE = CreateObject("InternetExplorer.Application") IE.navigate "webpage.com" IE.Visible = True While IE.Busy DoEvents Wend IE.document.all("lookupNumberId").Value = ThisWorkbook.Sheets("Sheet1").Range("a1") IE.document.all("Action").Click 'error 438 IE.document.getElementByName("Action").Click 'error 438 End Sub
-
BruceWayne almost 6 yearsIs there a single element with that name on the page?
-
Eric almost 6 yearsYes, that's the only element with that name.
-
BruceWayne almost 6 yearsTry
IE.document.getElementsByName("Action")(0).Click
-
Yorik almost 6 yearsI think
IE.document.getElementByName("Action")
returns an array (or array-like collection), and then you'd need to figure out which item is the right one. If its the only one, you might insert(0)
between("Action")
and.Click
-
Eric almost 6 yearsI tried BruceWayne's suggesting and this time I did not get an error message but nothing happen. But I changed
(0)
to(1)
and it worked. Thank you so much. -
Rajesh Sinha almost 6 yearsI think the code is looking for actual keypress event ! Tell me are you searching in WBK?
-