excel vba - select drop-down list by text not value -
i trying write excel vba script navigate website , select drop-down list using text in list item, not value of index. examining html code, can see values in drop-down list appear integers no recognizable pattern , not appear correlate text shown entry in drop-down list.
<option value="246">new2</option> <option value="245">new</option> <option value="196">test</option>
i can use following command:
iedoc.getelementbyid("viewmaintainfixedcombustible_fixedcombustible_firezoneid").value = 246
to select item "new2" drop-down list, sending value 246. or, send 245 select "new". however, elements in list changing, selecting value (246, 245, etc.) impractical. thus, searching way select entry drop-down list (e.g. "new2") sending text name of entry (e.g. "new2") in vba.
does have method how this?
try below sample code set dropdown list text.
set drp =iedoc.getelementbyid("<id of dropdown>") x = 0 drp.options.length - 1 if drp.options(x).text = "new2" drp.selectedindex = x exit end if next
Comments
Post a Comment