Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

runtime error 462 with internet explorer

Tags:

excel

vba

I am trying to access a webpage from excel using VBA. I can get internet explorer to launch, and I see the webpage come up, but I get a runtime error 462 when I hit the Do Until internet.ReadyState >= 4 line of code. any ideas? ultimately I want to be able to parse a site and get a list of the links on that site and pick one, and then "click" on that link. suggestions and help would be great. here is the function (that I found on the web) that I am using:

Public Sub clicklick()

Dim internet As Object
Dim internetdata As Object
Dim div_result As Object
Dim header_links As Object
Dim link As Object
Dim URL As String

Set internet = CreateObject("InternetExplorer.Application")
internet.Visible = True

URL = "https://www.google.co.in/search?q=how+to+program+in+vba"
internet.Navigate URL


Do Until internet.ReadyState >= 4
    DoEvents
Loop

Application.Wait Now + TimeSerial(0, 0, 5)

Set internetdata = internet.Document
Set div_result = internetdata.getelementbyid("res")


Set header_links = div_result.getelementsbytagname("h3")

For Each h In header_links
    Set link = h.ChildNodes.Item(0)
    Cells(Range("A" & Rows.count).End(xlUp).row + 1, 1) = link.href
Next

MsgBox "done"

End Sub

thank you, alan

like image 208
user3610196 Avatar asked Aug 31 '25 06:08

user3610196


1 Answers

I had a similar error with VBA and using Set objIE = New InternetExplorerMedium instead of Set objIE = CreateObject("InternetExplorer.Application") did not solve the problem. I solved the issue by going to IE Settings -> Internet Options -> Security and unchecking the "Enable protected Mode" option Settings

like image 130
Sachu Avatar answered Sep 02 '25 20:09

Sachu