I was following the following video to try to create a section for a code to pull basic information on companies from the google knowledge panel to populate into an excel spreadsheet. In my example, I am trying to capture the address text for the company: 10 Huntington Ave, Boston, MA 02116.
Video: https://www.youtube.com/watch?v=IOzHacoP-u4
When I run the code, I get Run-time error '91'
Sub Get_Web_Data()
Dim request As Object
Dim response As String
Dim html As New HTMLDocument
Dim website As String
Dim address As Variant
website = "https://www.google.com/search?q=Weston Copley 10 Huntington Ave, Boston, MA"
Set request = CreateObject("MSXML2.XMLHTTP")
request.Open "GET", website, False
request.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
request.send
response = StrConv(request.responseBody, vbUnicode)
html.body.innerHTML = response
address = html.getElementsByClassName("LrzXr")(0).innerText
MsgBox address
End Sub
The issue is associated with this line:
address = html.getElementsByClassName("LrzXr")(0).innerText
I have activated all the references specified in the video. Thanks!