When running the enclosed macro, I receive a Object variable or With block variable not set, error Line <code> trlen = tr.ChildNodes.Length <code>
any help or suggestions would be appreciated.
Sub RotoWire_Pitchers()
Dim k As Integer
Dim trlen As Long
Dim i As Long
Dim j As Integer
Dim tr As Object
Dim th As Object
Set XMLHTTP = CreateObject("MSXML2.XMLHTTP")
Dim XMLHttpRequest As MSXML2.XMLHTTP
Dim URLa As String
Dim HTMLDoc As HTMLDocument
'On Error Resume Next
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Sheets("PITCHER REPORT").Select
URLa = "http://www.rotowire.com/baseball/player_stats.htm?league=3&pos=P&filter=A"
Set XMLHttpRequest = New MSXML2.XMLHTTP
XMLHttpRequest.Open "GET", URLa, False
XMLHttpRequest.send
Set HTMLDoc = New HTMLDocument
HTMLDoc.body.innerHTML = XMLHttpRequest.responseText
Set tr = HTMLDoc.getElementsByTagName("tbody")(91)
trlen = tr.ChildNodes.Length
'Range("A1").Value = trlen
For i = 1 To trlen - 1
tdlen = 20
For j = 0 To tdlen - 1
Cells(i + 1, j + 2).Value = tr.ChildNodes(i).ChildNodes(j).innerText
Next j
Next i
Set tr = Nothing
Set HTMLDoc = Nothing
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Bookmarks