LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15
Default Why is this code not working ?

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. -
----------------------------------------------------------------------------
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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code not working JMay Excel Programming 5 March 16th 10 07:13 PM
another code not working Moh Excel Programming 4 December 17th 07 04:13 PM
VB code is not working like it should Bob Reynolds[_3_] Excel Programming 8 July 19th 04 12:02 AM
Code not working Bob Phillips[_5_] Excel Programming 5 August 14th 03 03:12 PM
For Each Code Not Working jacqui[_2_] Excel Programming 4 July 29th 03 02:44 AM


All times are GMT +1. The time now is 01:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"