I
ian bartlett
I recieved this code from Tim Williams and at the time I thought it did what
I wanted, but now I've noticed that its not importing all the web pages,
when you watch the import you can see it start to load say page 7 then it
quickly changes to page 8.
Any ideas ??
Thanks in advance
Bart
'***********************************
Sub playoffs()
Dim IE As Object, allCells, r, c, x, rw As Long
Dim row, numPage
rw = 2
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
For numPage = 1 To 12
**All 1 line ** IE.Navigate
"http://www.nhl.com/nhlstats/app?service=page&page=" & _
"Stats&fetchKey=20083ALLSASAll&viewName=summary&sort=points&pg="
& numPage
Do While IE.ReadyState <> 4 'READYSTATE_COMPLETE
DoEvents
Loop
Set r = Nothing
Set allCells = IE.document.getElementsByTagName("td")
For Each c In allCells
If c.innerText Like "Play*" Then
c.Style.Border = "1px solid #FF0000"
Set r = c.ParentElement.ParentElement.ParentElement 'containing
Table
c.Style.Border = "1px solid #0000FF"
Exit For
End If
Next c
If Not r Is Nothing Then
For Each row In r.Rows
For x = 1 To row.Cells.Length - 1
Sheet3.Cells(rw, x).Value = row.Cells(x - 1).innerText
Next x
rw = rw + 1
Next row
End If
Next numPage
End Sub
I wanted, but now I've noticed that its not importing all the web pages,
when you watch the import you can see it start to load say page 7 then it
quickly changes to page 8.
Any ideas ??
Thanks in advance
Bart
'***********************************
Sub playoffs()
Dim IE As Object, allCells, r, c, x, rw As Long
Dim row, numPage
rw = 2
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
For numPage = 1 To 12
**All 1 line ** IE.Navigate
"http://www.nhl.com/nhlstats/app?service=page&page=" & _
"Stats&fetchKey=20083ALLSASAll&viewName=summary&sort=points&pg="
& numPage
Do While IE.ReadyState <> 4 'READYSTATE_COMPLETE
DoEvents
Loop
Set r = Nothing
Set allCells = IE.document.getElementsByTagName("td")
For Each c In allCells
If c.innerText Like "Play*" Then
c.Style.Border = "1px solid #FF0000"
Set r = c.ParentElement.ParentElement.ParentElement 'containing
Table
c.Style.Border = "1px solid #0000FF"
Exit For
End If
Next c
If Not r Is Nothing Then
For Each row In r.Rows
For x = 1 To row.Cells.Length - 1
Sheet3.Cells(rw, x).Value = row.Cells(x - 1).innerText
Next x
rw = rw + 1
Next row
End If
Next numPage
End Sub