Bonjour à tous,

Je suis nouveau sur le forum, je travaille sur le val d'europe.

Je cherche à recupérer des données sur une station météo.

Pour cela j'ai écris le programme ci-dessous

Néanmoins, pour la bonne transcription des données, j'aurai besoin de me faire passer pour un navigateur internet du style Chrome.

Tous les bouts de codes que je rajoute jusqu'ici font bugger la macro.

Avez-vous une idée ?

Merci

Emmanuel

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Sub copie_internet()
 
' déf de inconnu
  Dim Station As Variant
 
    Dim début As Variant
    Dim fin As Variant
    Dim année_début As Variant
    Dim mois_début As Variant
    Dim jour_début As Variant
 
  Station météo = Application.InputBox("Indiquer la référence de la station météo")
  début = Application.InputBox("Indiquer la date de début de l'étude. ATTENTION sous format MM/JJ/AAAA")
  fin = Application.InputBox("Indiquer la date de fin de l'étude. ATTENTION sous format MM/JJ/AAAA")
 
  Sheets("Calcul").Select
    Range("AA2").Select
    ActiveCell.FormulaR1C1 = (début)
    Range("AB2").Select
    ActiveCell.FormulaR1C1 = (fin)
    Range("AD2").Select
    ActiveCell.FormulaR1C1 = (Airport)
 
 année_début = Range("AA3")
 mois_début = Range("AA4")
 jour_début = Range("AA5")
 nbre_jour = Range("AC2")
 
 
'copie donnée page web sur excel
 
Sheets("Feuil1").Select
 With ActiveSheet.QueryTables.Add(Connection:= _
 "URL;http://www.monsite.com/" & (Station) & "/" & (année_début) & "/" & (mois_début) & "/" & (jour_début) & "/DailyHistory.html?format=1#bas", _
 Destination:=Range("a1"))
 
 .BackgroundQuery = True
 .TablesOnlyFromHTML = True
 .Refresh BackgroundQuery:=False
 .SaveData = True
 End With
 
    Range("A1").Select
    ActiveCell.Offset(0, 0).Range("A2:A500").Select
    Selection.Copy
    Sheets("données").Select
    Range("A1").Select
    ActiveSheet.Paste
    Sheets("Feuil1").Select
 
 Dim x As Variant
 
For x = (jour_début) + 1 To nbre_jour Step 1
 
 With ActiveSheet.QueryTables.Add(Connection:= _
 "URL;http://www.monsite.com/" & (Station) & "/" & (année_début) & "/" & (mois_début) & "/" & (x) & "/DailyHistory.html?format=1#bas", _
 Destination:=Range("a1"))
 
 .BackgroundQuery = True
 .TablesOnlyFromHTML = True
 .Refresh BackgroundQuery:=False
 .SaveData = True
 End With
 
    Range("A1").Select
    ActiveCell.Offset(0, 0).Range("A2:A500").Select
    Selection.Copy
    Sheets("données").Select
    Range("A1").Select
    Selection.End(xlDown).Select
    Selection.Offset(-1, 0).Select
    ActiveSheet.Paste
    Sheets("Feuil1").Select
 
 Next x
 
End Sub