Bonjour,

Je souhaite faire une recherche dans google via une macro excel. Mais ma macro bug a deux niveaux cf. ci-dessous. J'ai fait en sorte d'ajouter toutes les references necessaires dans VBA library a savoir: Microsoft HTML Object Library and Microsoft Internet Controls mais ca en marche toujours pas. Pouvez vous svp me conseiller? Merci

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
Sub RechercheGoogle()
Dim inputs As String
Dim IE As InternetExplorer
Dim maPageHtml As HTMLDocument
Dim InputGoogleZoneTexte As HTMLInputElement
'Dim InputGoogleBouton As HTMLInputElement
Dim FormGoogleCherche As HTMLFormElement
 
Range(Range("results"), Range("results").Offset(10, 0)).ClearContents
 
'On Error Resume Next
inputs = Range("inputs").Value
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = False
IE.navigate "http://news.google.fr/nwshp?hl=fr&tab=wn"
Do Until IE.readyState = READYSTATE_COMPLETE
DoEvents
Loop 'attend la fin du chargement
IE.Visible = False
Set IEDoc = IE.document
Set InputGoogleZoneTexte = IEDoc.all("q")
InputGoogleZoneTexte.Value = inputs
 
'Set InputGoogleBouton = IEDoc.all("gbqfb")
'InputGoogleBouton.Click
Set FormGoogleCherche = IEDoc.forms("gbqf")
FormGoogleCherche.submit ' Bug a ce niveau la
 
Do Until IE.readyState = READYSTATE_COMPLETE
DoEvents
Loop
 
Dim textExtract As String
 
Set element = IEDoc.getElementsByTagName("h3")
Set element = IEDoc.getElementsByTagName("h3")
 
Dim i As Integer
For i = 0 To 9
    textExtract = element.Item(i).innerText ' Bug a ce niveau la aussi
    Range("results").Offset(i, 0).Value = textExtract
Next i
 
IE.Quit
 
Set IE = Nothing
Set IEDoc = Nothing
 
End Sub
Pour plus de precisions, je recois Run-time error '91': Object variable or With block variable not set

Je vous serai tres reconnaissant si vous pouvez me faire un retour a ce sujet.

Merci par avance,