0

I got this awesome code from someone on here which gets the first URL from a list in a worksheet from Internet Explorer. Link is How to extract first Google search result URL?

The code has been working absolutely fine until the last week when I have been getting a "Run-time error '424': Object required" error message. I've not changed the code or done anything:

Option Explicit
Sub tryme()

Dim ie As New InternetExplorer
Dim lastrow As Integer
Dim i As Integer

lastrow = Range("A" & Rows.Count).End(xlUp).Row
    
    For i = 2 To lastrow
         
        ie.Visible = True
        ie.navigate Cells(i, 1)
        While ie.Busy Or ie.readyState < 4: DoEvents: Wend

        Cells(i, 2).Value = ie.document.querySelector("#search div.r [href*=http]").href
            **strong text**    
    Next

End Sub

What can I do to get it working again?

Thanks

user9601310
  • 1,076
  • 1
  • 7
  • 12
  • Are you sure you want to work on the *ActiveSheet*? What is the content of `Cells(i, 1`) at the moment the error occurs? Write the result of the `querySelector` into an intermediate variable and check the result with the debugger. – FunThomas Oct 12 '20 at 09:49
  • the content of cells(i, 1) is a google URL so e.g. https://www.google.co.uk#q=Workchain – Mitchell Johnson Oct 12 '20 at 10:00

0 Answers0