Question

Is there a way to select the innertext of the selected option for a webpages dropdown list? I was trying this way but kept getting an error Object Required:

Dim drp As Object
Set drp = IE.Document.getElementById("ctl05_Dropdownlist1").selectedindex
Range("J" & (ActiveCell.Row)) = drp.innertext

Im trying to pull the selected options innertext from the following part of HTML sourcecode:

<select name="ctl05$Dropdownlist1" id="ctl05_Dropdownlist1" disabled="disabled" class="input">
<option value=""></option>
<option selected="selected" value="1">*DIRECT ISSUE</option>
<option value="2">*DIWELD</option>
<option value="3">*INACTIVE</option>
Était-ce utile?

La solution

.selectedindex?

The Drop down is disabled. So how do you want to get the selected item?

If you want the dropdown's inner text, try this

Set drp = IE.Document.getElementById("ctl05_Dropdownlist1")
Debug.Print drp.innertext

Else if you want the innertext of a particular item say, item 1, then use this

drp.Item(1).innertext

FOLLOWUP FROM COMMENTS

If you want to retrieve what is displayed currently in the disabled dropdown then use this

Set drp = IE.Document.getElementById("ctl05_Dropdownlist1")
Range("J" & (ActiveCell.Row)) = drp.Item(drp.selectedIndex).innerText
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top