OVH Cloud OVH Cloud

Cliquer un bouton Internet Explorer via VB

2 réponses
Avatar
Yann
Bonjour,

j'aimerai savoir comment puis-je faire pour cliquer sur un
bouton d'un document HTML si le bouton ne porte pas de
nom ?

Voici mon code qui marche bien pour remplir les champs,
mais pour cliquer ...


Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")

IE.Visible = True
IE.Navigate "http://www.monsite.com/mapage.html"

Do While IE.ReadyState <> 4
DoEvents
Loop

IE.Document.All("IDENTIFIANT").Value = "MOI"
IE.Document.All("MOT_DE_PASSE").Value = "NIMP"

---> CETTE LIGNE PLANTE CAR LE BOUTON N'A PAS DE NOM
'IE.Document.All("BUTTON").Click

merci.

2 réponses

Avatar
ng
Salut,

Essaye avec un code du genre :

IE.Document.Forms(0).elements(0).Click

Ou si ton bouton sert à valider :

IE.Document.Forms(0).submit

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/

Yann a écrit :

Bonjour,

j'aimerai savoir comment puis-je faire pour cliquer sur un
bouton d'un document HTML si le bouton ne porte pas de
nom ?

Voici mon code qui marche bien pour remplir les champs,
mais pour cliquer ...


Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")

IE.Visible = True
IE.Navigate "http://www.monsite.com/mapage.html"

Do While IE.ReadyState <> 4
DoEvents
Loop

IE.Document.All("IDENTIFIANT").Value = "MOI"
IE.Document.All("MOT_DE_PASSE").Value = "NIMP"

---> CETTE LIGNE PLANTE CAR LE BOUTON N'A PAS DE NOM
'IE.Document.All("BUTTON").Click

merci.


Avatar
Correct, :o

IE.Document.Forms(0).submit

ca marche du feu de dieu.

en attendant, j'avais mis ca, mais c'était pas terrible :
Call SendKeys("{tab}")
DoEvents
Call SendKeys("{tab}")
DoEvents
Call SendKeys("{tab}")
DoEvents
Call SendKeys("{tab}")
DoEvents
Call SendKeys("{tab}")
DoEvents
Call SendKeys("{enter}")

afin de me positionner sur le bouton et cliquer.

MERCI !

-----Message d'origine-----
Salut,

Essaye avec un code du genre :

IE.Document.Forms(0).elements(0).Click

Ou si ton bouton sert à valider :

IE.Document.Forms(0).submit

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/

Yann a écrit :

Bonjour,

j'aimerai savoir comment puis-je faire pour cliquer sur




un
bouton d'un document HTML si le bouton ne porte pas de
nom ?

Voici mon code qui marche bien pour remplir les champs,
mais pour cliquer ...


Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")

IE.Visible = True
IE.Navigate "http://www.monsite.com/mapage.html"

Do While IE.ReadyState <> 4
DoEvents
Loop

IE.Document.All("IDENTIFIANT").Value = "MOI"
IE.Document.All("MOT_DE_PASSE").Value = "NIMP"

---> CETTE LIGNE PLANTE CAR LE BOUTON N'A PAS DE NOM
'IE.Document.All("BUTTON").Click

merci.




.