Bonjour
Le code dans ma base Acces 2010 ci-dessous qui me permettait de lancer IE et de remplir automatiquement des champs fonctionnait sous XP mais plus sous W7. Tout se passe correctement jusqu'à l'instruction "Set docmnt = IEecran.Document"
où se produit le message : "erreur -2147467259, erreur automation erreur non spécifiée"
J'ai essayé d'ajouter des références mais rien n'y fait, actuellement j'ai Visual Basic pour application, Microsoft acces 14.0 object library, OLA automation, Microsoft html object library, microsoft intrenet controls, microsoft shell and automation, Microsoft activex dtaobject 2.8 library.
Voic le code (classique trouvé sur internet) :
Merci de votre aide
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
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