0

I have used this script here to get the results and it was working fine until I ran into the error.

Using VBA in Excel to Google Search in IE and return the hyperlink of the first result

Run time error '91':
Object variable with block variable not set.

When I hit debug it highlights the following line for me.

Set objH3 = objResultDiv.getelementsbytagname("H3")(0)

As I don't really understand VBA much I need some help with the script.

I suspect that there is some limit to the number of searches I can do using this script. As the script it not working even for the results it was working earlier. So due to lack of response it is getting into this error.

How do I go about it now?

PS: I could not post in that link itself as I apparently need 50 reputation points.

Community
  • 1
  • 1
Rahul
  • 51
  • 3

1 Answers1

0

I think the problem is coming from the previous line in script

Set objResultDiv = html.getelementbyid("rso")

When this is executed it looks for an html element with the id "rso". If it doesn't find the element than the objResultDiv is not set. When you subsequently try to use in the line highlighted it throws the error 91.

Looking at the original script it could be because of gaps in column A values, the script assumes that down to the last used row in the spreadsheet there will be a value in column A, otherwise google is sent an empty request and hence the lack of an element "rso" in the return text.

Graham Anderson
  • 1,209
  • 10
  • 17