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
| 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
'Nous attendons un peu que la page se charge
While IE.Busy
DoEvents
Wend
Application.Wait (Now + TimeValue("0:00:02"))
IE.document.getElementById("lst-ib").Value = var
'Ici nous cliquons sur le bouton Chercher
Set form = IE.document.getElementsByTagName("form")
Application.Wait (Now + TimeValue("0:00:02"))
Set button = form(0).onsubmit
form(0).submit
'Nous attendons que la page se charge
While IE.Busy
DoEvents
Wend
Application.Wait (Now + TimeValue("0:00:02"))
Set var1 = IE.document.getElementById("resultStats")
Cells(x, 2).Value = var1.innerText
IE.Quit
Set IE = Nothing
Next x
End Sub |
Partager