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
| Private Sub CommandButton1_Click()
Dim IE As Object
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "http://xxx" 'ouverture site xxx
Do Until .readyState = 4 And .busy = False: DoEvents: Loop 'attente fin d'ouverture
'Remplissage du formulaire
With .document
With .getElementsByTagName("input")
.Item("login").Value = "xx"
.Item("password").Value = "xx"
End With
Do: Loop Until .readyState = "complete"
End With
' click bouton se connecter
With .document
Set elems = .getElementsByTagName("input")
For Each e In elems
If (e.getAttribute("value") = "Se connecter") Then
e.Click
Exit For
Application.StatusBar = "Search form submission. Please wait..."
End If
Next e
Application.Wait Time + TimeSerial(0, 0, 3)
'print innerHTML (source code) of the 'new' website
Range("A1") = .DocumentElement.innerHTML[/COLOR]
End With
End With
End Sub |
Partager