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 55
|
Public Function LanceExplo() As Object
Dim Msg As String
Dim docmnt As MSHTML.HTMLDocument
Dim frm As MSHTML.HTMLFormElement
Dim blnFormOK As Boolean
Dim afd As AuthFormDef
Dim IEecran As InternetExplorer
Dim Obj As Object
On Error GoTo ErrLance:
With afd
.URL = Pagelog
.UserValue = Loglog
.PasswordValue = Passlog
.UserField = "j_username"
.PasswordField = "j_password"
.FormAction = "j_security_check"
End With
Set IEecran = CreateObject("InternetExplorer.Application") 'crée un objet internet Explorer
IEecran.Visible = True
IEecran.Navigate afd.URL
While IEecran.Busy
DoEvents
Wend
Set docmnt = IEecran.Document 'PLANTE ICI
For Each frm In docmnt.Forms
' Trouver et renseigner les champs Identifiant/Mot de passe
' du formulaire
For Each Obj In frm.elements
If Obj.Name = afd.UserField Then Obj.Value = afd.UserValue
If Obj.Name = afd.PasswordField Then Obj.Value = afd.PasswordValue
Next
' Forcer l'envoi du formulaire
frm.submit
'End If
Next
Set LanceExplo = IEecran
Exit Function
ErrLance:
MsgBox "Erreur : " & Err.Number & vbCrLf _
& Err.Description, vbExclamation
Exit Function
End Function |
Partager