IE Alimenter un élément et click bouton définis dans une <form>
Bonjour,
J'essaie de piloter une page web depuis VBA.
La page est affichée, code ci-dessous. Tu peux l'exécuter pour l'afficher.
Code:
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
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Modification de photo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="737" align="center">
<tr><td><style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
color: #8C8C8C;
text-decoration:none;
}
-->
</style>
<a href="https://www.cistes.net"><img src="images/fr/navigation/rappel.jpg" width="737" height="98" alt="cistes.net" border="0"></a>
</td></tr>
<tr><td>
<p align="center"><font face="Arial" size="4">Modification de la photo d'une ciste</font></p>
<p align="center"><font face="Arial" size="3"><strong>Ciste N° : </strong> 56909 Vrai faux doublon</font></p>
<p align="center"><strong><font face="Arial" color="#FF0000"></font></strong></p>
<p align="center"><font face="Arial" size="4">Attention : Si cette ciste a une photo, la référence vers celle-ci sera complètement perdue</font></p>
<p align="center"><font face="Arial" size="4">Ne vous trompez pas.... Il n'y a pas de retour en arrière possible</font></p>
<form name="valid" method="post" enctype="multipart/form-data" action="infosmodifphoto.php">
<input type="hidden" name="vaction" value="1">
<input type="hidden" name="id" value="56909">
<p align="center"><font face="Arial" size="3"><strong>Nouvelle image (rappel : 100 Ko max, format jpg ou gif) : </strong></font><input type="file" name="newphoto"></p>
<p align="center"><input type="submit" value="Valider" name="Valider"></p>
</form>
</td></tr>
</table>
<center>
<p><a href="infoscistesc.php"><img src="../images/fr/navigation/retour.gif" border="0" width="101" height="38" alt=""></a></p>
</center>
</body>
</html> |
1. Je n'arrive pas à alimenter l'élément "nouvelle photo" : name="newphoto".
J'ai utilisé
Code:
1 2 3 4 5
| fichier = Application.GetOpenFilename("image(*.jpg),*.jpg")
If Dir(fichier) <> "" Then
Set DOCelement = IE.Document.getElementsByName("newphoto").Item
DOCelement.Value = fichier
End if |
Mais ça ne marche pas.
newphoto fait partie de la form valid, est-ce pour çà ? Comment coder ?
2. Puis je souhaite simuler un click sur "Valider", et là j'ai eu beau chercher je n'ai pas trouvé comment faire.
J'ai essayé plein de choses. Je n'arrive pas à trouver le bon code. Je fais appel à vous pour te tirer de cette impasse.
Merci d'avance.