Using excel vba to change the value of a dropdown menu on a website

drop-down-menu, excel, internet-explorer, vba, web-scraping

Solution

`doc.getElementById("xs_r_gender").selectedindex=1` seems to do the trick. (Where 1 represents male)

Though it means I will need to do alot of lookups to determine what the value is for the items in my dropdown. (Easy enough for Sex, where there are only two options, but I have some comboboxes with up to 50 options). If anyone knows of a faster solution, that'd be great. In the meantime, Ill start doing up some tables!!!

thanks.

Problem

I am writing an Excel macro to fill out a form on a website. I have written the code that populate the text boxes easily enough, and found code to chose radio boxes, but I am having problems with choosing info from dropdown menus. Example 'Gender': The combo box has three options: ``` Select / Male / Female ``` I've tried a few variations on this: ``` doc.getElementsByName("xs_r_gender").Item(0).Value="Male" ``` ...but with no luck. This is the web source code: ``` <td> <select name="xs_r_gender" id="xs_r_gender"> <option value="" selected>Select</option> <option value="male">Male</option> <option value="female">Female</option> </select></td> ``` Thanks.

Original source