Reputation: 155
I'd like my VBA code to fill the date field on a particular website with the date 1990-02-22.
Here is the source code of the element whose field I need to fill in:
<input id="mainDriver.dateOfBirth" name="mainDriver.dateOfBirth" class="sg-Input user-success" data-date-split-input="true" max="2015-08-14" placeholder="yyyy-mm-dd" data-date-nopicker="true" type="date" value="">
I've tried several variations of the following code:
IE.Document.getElementById("mainDriver.dateOfBirth").Value = DateValue(1990 - 02 - 22)
e.g. I've also tried this:
IE.Document.getElementById("mainDriver.dateOfBirth").Value = DateValue("February 22, 1990")
... which seems to be the way to express the DateValue argument according to what I searched online.
In both of the cases above the page is not affected - and no error is provided in the code to debug.
Any help would be greatly appreciated.
If you'd like to see exactly where that field is, you could manually fill in the IE fields up until that point. The IE page is here.
And you could use the following example for address information when you get to those fields:
Postcode: COOKS HILL, 2300, NSW
Street Address: 33 Bull Street
Otherwise you could randomly choose / select the values of the other fields, from the dropdowns etc.
Upvotes: 2
Views: 740
Reputation: 155
I figured it out in the end. It was a matter of copying the format of date shown in the source code, i.e.
max="2015-08-14" placeholder="yyyy-mm-dd"
... and then simply using the value property. So the following worked:
IE.document.getElementById("mainDriver.dateOfBirth").Value = "1990-02-10"
For some reason it doesn't actually display the DOB when the code is excecuted but the date is stored and used properly, thus allowing you to finish fill in the form.
Otherwise thanks for looking!
Upvotes: 3