Bonjour,
J'ai essayé ce code mais il ne fonctionne pas sur mon ordinateur. J'ai Excel 2010 et Windows 10.
Le but est de récolté les nombres d'enregistrements que le moteur de recherche trouve par rapport à un mot.
Dans la feuille Excel, j'ai mis ceci (voir écran)
Le code VBA est le suivant :
Pour information, la variable ie.document ne contient rien. Et je ne comprend pas pourquoi.
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 Sub SearchGoogle() Dim ie As Object Dim form As Variant Dim button As Variant Dim LR As Integer Dim var As String Dim var1 As Object LR = Cells(Rows.Count, 1).End(xlUp).Row For x = 2 To LR var = Cells(x, 1).Value Set ie = CreateObject("internetexplorer.application") ie.Visible = True With ie .Visible = True .navigate "http://www.google.fr" While Not .readyState = READYSTATE_COMPLETE Wend End With While ie.Busy DoEvents Wend Application.Wait (Now + TimeValue("0:00:02")) ie.document.getElementById("lst-ib").Value = var Set form = ie.document.getElementsByTagName("form") Application.Wait (Now + TimeValue("0:00:02")) Set button = form(0).onsubmit form(0).submit While ie.Busy DoEvents Wend Set var1 = ie.document.getElementById("resultStats") Cells(x, 2).Value = var1.innerText ie.Quit Set ie = Nothing Next x End Sub
Merci de votre aide
PS : Ce code provient d'un magazine informatique ("Micro Portable")
Partager