none
Runtime error 462 from excel VBA when trying to access a webpage RRS feed

  • Question

  • 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

    Sunday, February 5, 2017 2:55 AM

All replies

  • Hi eecewolf,

    I try to test your code on my side.

    when I run the code I find that you did not create a variable "h" that you used in for each loop.

    so I create that "h" variable as an object.

    then run the code.

    code run without any error on Do Until statement.

    below is the output I get.

    please try to correct your code and again try to test it. let me know about the results.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 6, 2017 2:49 AM
    Moderator
  • Hi, i have a similar problem accesing EXCEl from MS ACCESS, and the solution was deactivate a COM add in call DAX Studio.

    Maybe is off topic but, i read a lot of post and nothigs works.

    Because the solution was so simple, the concept of disable add ins first could be heplful for somebody. Some add ins of excel can make VBA to fail.

    Bye

    Alvaro J.

    Monday, May 8, 2017 5:15 PM