J'ai le code suivant dans VBA qui ouvre une page IE, la remplit puis clique sur un bouton qui ouvre une nouvelle fenêtre IE. Cependant, mon code n'est pas capable de remplir la première liste déroulante de la nouvelle fenêtre. Toute aide serait grandement appréciée.Web Scraper ne remplira pas une fenêtre enfant que mon code VBA lance
Sub Van()
Dim IE As Object
Dim IE2 As Object
Set IE = CreateObject("InternetExplorer.Application")
'Set IE2 = CreateObject("InternetExplorer.Application")
IE.navigate ("website")
IE.Visible = True
Do
DoEvents
Loop Until IE.readystate = 4
Set d = IE.document
'Code now clicks on buttons or dropdowns etc
Application.Wait (Now + TimeValue("00:00:03"))
Set IE2 = GetIE("pop-up page")
WaitFor IE2
'Tried this too
'Application.Wait (Now + TimeValue("00:00:05"))
IE2.document.getElementsByTagName("select")(0).Value = "X"
'Also tried the line below
'IE2.document.GetElementsbyname("name")(0).SelectedIndex = 1
End Sub
Function GetIE(sAddress As String) As Object
Dim objShell As Object, objShellWindows As Object, o As Object
Dim retVal As Object, sURL As String
Set retVal = Nothing
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows
'see if IE is already open
For Each o In objShellWindows
sURL = ""
On Error Resume Next
sURL = o.LocationURL
On Error GoTo 0
If sURL <> "" Then
'MsgBox sURL
If sURL = sAddress Then
Set retVal = o
Exit For
End If
End If
Next o
Set GetIE = retVal
End Function
Sub WaitFor(IE)
Do
DoEvents
Loop Until IE.readystate = 4
End Sub
Avez-vous vraiment ces espaces après la '' dans l'URL vous passez? à 'GetIE'? –
Non, désolé, c'est juste la façon dont j'ai copié par erreur ici - Je vais le modifier – chris