Hello,
I just finished watching your tutorial, "Import web data to Excel using VBA Macros". I am receiving a run-time error '91' : Object variable or With block variable not set. Below is the code I am using. Please help!
Sub Get_web_Data()
Dim Request As Object
Dim response As String
Dim html As New HTMLDocument
Dim website As String
Dim price As Variant
' Website to go to.
website = "http://www.freddiemac.com/pmms/"
'Create the object that will make the webpage request.
Set Request = CreateObject("MSXML2.XMLHTTP")
'Where to go and how to go there - propobly don't need to change this.
Request.Open "GET", website, False
'Get fresh data.
Request.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
'Send the request for the webpage.
Request.send
'Get the webpage response data into a variable.
response = StrConv(Request.responseBody, vbUnicode)
' Put the webpage into an html object to make data references easier.
html.body.innerHTML = response
' Get the price from the specified element on the page.
PMMS = html.getElementsByClassName("mortgage-rate-widget__rate-value")(0).innerText
'Output the PMMS rate into a message box.
MsgBox PMMS_Rate
End Sub
Thank you in advance!!