Rick;
I've encountered with the same error. I am using Excel 2010 (32 Bit) on Win7-Home (64 bit).
I changed the 2nd part of the code and instead of using "WinHttp.WinHttpRequest" I used "MSXML2.XMLHTTP" object.
Here is the revised code that works fine for me;
Sub Test()
'Haluk - 18/07/2019
'sa4truss@gmail.com
Dim xmlHTTPReq As Object
Dim postURL As String
Dim L As Long
postURL = "https://www.wsj.com/market-data/bonds"
With ActiveSheet.QueryTables.Add(Connection:="URL;" & postURL, Destination:=Range("$B$2"))
.Name = "myQuery"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebTables = 1
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Set xmlHTTPReq = CreateObject("MSXML2.XMLHTTP")
With xmlHTTPReq
.Open "GET", postURL, False
.send
End With
L = InStr(xmlHTTPReq.responseText, "Rates shown are effective")
If L Then ActiveSheet.Range("A12") = Mid(xmlHTTPReq.responseText, L, InStr(L, xmlHTTPReq.responseText, "</") - L)
Set xmlHTTPReq = Nothing
End Sub
.
Bookmarks