Sub Turf()
Dim f As Worksheet
Dim ScriptControl As Object, PMU As Object, prog As Object, reu As Object, r As Object, hippo As Object
Dim Site As String, i As Long
suppfeuilles
Range("A1").CurrentRegion.Offset(2, 0).ClearContents
Set ScriptControl = CreateObject("MSScriptControl.ScriptControl")
ScriptControl.Language = "JScript"
Site = Range("C1").Value
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", Site, False
.send
Set PMU = ScriptControl.Eval("(" + .responseText + ")")
.abort
End With
i = 3
Set prog = PMU.programme
Set reu = prog.reunions
'On Error Resume Next
For Each r In reu
With ActiveSheet
.Cells(i, 1).Value = "R" & r.numOfficiel
Set hippo = r.hippodrome
.Cells(i, 2).Value = hippo.libelleCourt
i = i + 1
End With
Next r
Set PMU = Nothing
Set ScriptControl = Nothing
End Sub
Sub Turf2()
Dim ScriptControl As Object, PMU As Object, cou As Object, c As Object
Dim Site As String, i As Long
suppfeuilles
Range("A1").CurrentRegion.Offset(2, 2).ClearContents
If Not Cells(Selection.Row, 1) Like "R*" Then
MsgBox "Sélectionner eune réunion !"
Exit Sub
End If
Set ScriptControl = CreateObject("MSScriptControl.ScriptControl")
ScriptControl.Language = "JScript"
Site = Range("C1").Value & Cells(Selection.Row, 1) & "/"
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", Site, False
.send
Set PMU = ScriptControl.Eval("(" + .responseText + ")")
.abort
End With
i = Selection.Row
ActiveSheet.Cells(Selection.Row, 3) = ">>>"
Set cou = PMU.courses
'On Error Resume Next
For Each c In cou
With ActiveSheet
.Cells(i, 4).Value = .Cells(Selection.Row, 1) & "/C" & c.numOrdre
.Cells(i, 5).Value = c.libelle
i = i + 1
End With
Next c
Set PMU = Nothing
Set ScriptControl = Nothing
Turf3
End Sub
Sub Turf3()
Dim f As Worksheet, newf As Worksheet
Dim ScriptControl As Object, PMU As Object
Dim Ecurie As Object, Cheval As Object, Drd As Object, Gp As Object
Dim Site As String, li As Long
Set f = ActiveSheet
reunion = f.Range("B" & Selection.Row)
For i = Selection.Row To f.Range("D" & Rows.Count).End(xlUp).Row
RC = f.Range("D" & i)
Set newf = Sheets.Add(After:=Sheets(Sheets.Count))
newf.Name = Replace(RC, "/", " ")
Set ScriptControl = CreateObject("MSScriptControl.ScriptControl")
ScriptControl.Language = "JScript"
Site = f.Range("C1").Value & RC & "/participants"
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", Site, False
.send
Set PMU = ScriptControl.Eval("(" + .responseText + ")")
.abort
End With
li = 2
newf.Cells(1, 1) = f.Range("B1")
newf.Cells(1, 1).NumberFormat = "[$-F800]dddd, mmmm dd, yyyy"
newf.Cells(1, 2) = "Cheval"
newf.Cells(1, 3) = "Cote"
newf.Cells(1, 4) = reunion
newf.Cells(1, 5) = f.Range("E" & i)
Set Ecurie = PMU.participants
On Error Resume Next
For Each Cheval In Ecurie
With ActiveSheet
newf.Cells(li, 1).Value = Cheval.numPmu
newf.Cells(li, 2).Value = Cheval.nom
Set Drd = Cheval.dernierRapportDirect
newf.Cells(li, 3).Value = Drd.rapport
li = li + 1
End With
Next Cheval
newf.Cells.EntireColumn.AutoFit
Set PMU = Nothing
Set ScriptControl = Nothing
Next
f.Select
End Sub
Sub suppfeuilles()
Dim f As Worksheet
For Each f In Worksheets
Application.DisplayAlerts = False
If f.Name <> ActiveSheet.Name Then f.Delete
Application.DisplayAlerts = True
Next
End Sub