Anthony
Anthony

Reputation: 552

How to select an option on a website using VBA?

I have the code below on a website from which I am trying to extract a report. I have managed to navigate to the site a click the relevant buttons to select the report but I have no clue how to select the From date and the Too date. Any help will be greatly appreciated.

<select name="dlsPeriodFrom"id="dlsPeriodFrom" class="Items">
    <option selected="selected" value="484">Aug 2017</option>
    <option value="483">Jul 2017</option>
    <option value="482">Jun 2017</option


                <select name="dlsPeriodToo"id="dlsPeriodToo" class="Items">
    <option selected="selected" value="484">Aug 2017</option>
    <option value="483">Jul 2017</option>
    <option value="482">Jun 2017</option                        

Upvotes: 1

Views: 889

Answers (1)

SierraOscar
SierraOscar

Reputation: 17637

Assuming you already have the rest of the IE automation in place:

document.getElementById("dlsPeriodFrom").value = "483"
document.getElementById("dlsPeriodToo").value = "483"

Basically, you have to get the <select> element and set it's value to the value of the relevant <option>

Upvotes: 2

Related Questions