M
musicalhacksaw
When I press the CommandButton1 (an 'Active x' control button on the worksheet page) it says 'Sub missing' and a yellow arrow points to the
first line. re:-
----------------------------------------------------------------------------
Private Sub CommandButton1_Click()
Sub GetHorses()
Dim IE As Object
Dim doc As Object
Dim divRunners As Object
Dim divHorse As Object
Dim divCard As Object
Dim tblRaceHeader As Object
Dim elmt As Object
Dim lnk As Object
Dim strURL As String
Dim ws As Worksheet
Dim rng As Range
strURL = "http://www.racingpost.com/horses2/ca...ate=2011-06-20"
Set IE = CreateObject("InternetExplorer.Application")
With IE
.navigate strURL
Do While .Busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop
.Visible = True
Set ws = Worksheets.Add
Set rng = ws.Range("A1")
Set doc = IE.Document
' this small table has the stat headers
Set tblRaceHeader = doc.getelementbyid("lc_cardHead")
GetTableData tblRaceHeader, rng
ws.Range("B1").Insert xlShiftToRight
ws.Range("B1") = "FORM"
Set rng = rng.Offset(1)
Set divRunners = doc.getelementbyid("lc_sortBlock")
Set divRunners = divRunners.getelementsbytagname("DIV")
For Each divHorse In divRunners
If divHorse.classname = "cardItem" Then
For Each elmt In divHorse.all
Select Case elmt.tagname
Case "TABLE"
Select Case elmt.classname
Case "cardGl" ' this table has the runners and stats
GetTableData elmt, rng
End Select
Case "P"
End Select
Next elmt
End If
Next divHorse
IE.Quit
Set IE = Nothing
End With
ws.Cells.WrapText = False
ws.Range("A1:J1").EntireColumn.AutoFit
Application.Goto Worksheets(1).Range("A1"), Scroll:=True
End Sub
----------------------------------------------------------------------------
Can anyone tell me what is amiss ? I copied this code from the internet, but it is meant to work - everybody was saying what a genius the author was.
Thank you for your help.
Yours
Simon
first line. re:-
----------------------------------------------------------------------------
Private Sub CommandButton1_Click()
Sub GetHorses()
Dim IE As Object
Dim doc As Object
Dim divRunners As Object
Dim divHorse As Object
Dim divCard As Object
Dim tblRaceHeader As Object
Dim elmt As Object
Dim lnk As Object
Dim strURL As String
Dim ws As Worksheet
Dim rng As Range
strURL = "http://www.racingpost.com/horses2/ca...ate=2011-06-20"
Set IE = CreateObject("InternetExplorer.Application")
With IE
.navigate strURL
Do While .Busy: DoEvents: Loop
Do While .ReadyState <> 4: DoEvents: Loop
.Visible = True
Set ws = Worksheets.Add
Set rng = ws.Range("A1")
Set doc = IE.Document
' this small table has the stat headers
Set tblRaceHeader = doc.getelementbyid("lc_cardHead")
GetTableData tblRaceHeader, rng
ws.Range("B1").Insert xlShiftToRight
ws.Range("B1") = "FORM"
Set rng = rng.Offset(1)
Set divRunners = doc.getelementbyid("lc_sortBlock")
Set divRunners = divRunners.getelementsbytagname("DIV")
For Each divHorse In divRunners
If divHorse.classname = "cardItem" Then
For Each elmt In divHorse.all
Select Case elmt.tagname
Case "TABLE"
Select Case elmt.classname
Case "cardGl" ' this table has the runners and stats
GetTableData elmt, rng
End Select
Case "P"
End Select
Next elmt
End If
Next divHorse
IE.Quit
Set IE = Nothing
End With
ws.Cells.WrapText = False
ws.Range("A1:J1").EntireColumn.AutoFit
Application.Goto Worksheets(1).Range("A1"), Scroll:=True
End Sub
----------------------------------------------------------------------------
Can anyone tell me what is amiss ? I copied this code from the internet, but it is meant to work - everybody was saying what a genius the author was.
Thank you for your help.
Yours
Simon