VBA : Sélectionner une valeur dans une liste déroulante sur website
Bonjour
J'aimerai choisir dans une liste déroulante d'un site web une valeur parmi d'autres, je n'est aucune information sur son numéro d'index
j'ai commencé par ce code :
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 42 43 44 45 46
| Sub SAISIE()
Dim IE As Object
Dim usrName As String: usrName = "XXXX"
Dim usrPassword As String: usrPassword = "yyyyy"
Dim Site As String
Dim FldSite
Site = Range("I1").Value
Set IE = New InternetExplorer
With IE
.navigate "http://........"
.Visible = True
Do While .Busy: DoEvents: Loop 'waiting browser not busy
Do While .readyState <> 4: DoEvents: Loop 'Waiting for Document Ready
End With
Set fldUsrName = IE.document.getElementsByName("login")
Set fldUsrPassword = IE.document.getElementsByName("password")
Set btnSubmit = IE.document.getElementsByTagName("button")
If (fldUsrName.Length > 0) Then
'MsgBox (fldUsrName(0).GetAttribute("value"))
Call fldUsrName(0).setAttribute("value", usrName)
Call fldUsrPassword(0).setAttribute("value", usrPassword)
btnSubmit(0).Click
End If
IE.Visible = False
With IE
.navigate "http://................."
.Visible = True
Do While .Busy: DoEvents: Loop 'waiting browser not busy
Do While .readyState <> 4: DoEvents: Loop 'Waiting for Document Ready
End With
Set FldSite = IE.document.getElementById("select2-form-site-container")
FldSite.Value = Site
End Sub |
Voici le code du site
Code:
<span class="select2-selection select2-selection--single" role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-labelledby="select2-form-classe-container"><span class="select2-selection__rendered" id="select2-form-classe-container"><span class="select2-selection__placeholder">Selectionner une classe</span></span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span></span>
vers la fin j’obtiens l'erreur suivant :
Run time error '438'
Object doesn't support this property or method
Je vous remercie de me corriger le code
merci .