Using Sendkeys in IE. VBA code

  • Hello, I am working on a VBA code that will navigate through several links then enter a date range and run a report.


    As of now I have everything working except the Sendkeys function for entering the date range.



    As you can see in the code, on the last page I am prompted with 2 calendars for selecting the dates .


    The dates selected will ALWAYS be yesterday.


    When navigating through this via mouse, you simply click the calendar and press the left arrow then enter. This will input yesterdays date.


    Now for some reason my sendkeys line is not executing in IE.


    Is there anything I should add to this as to link it to IE or the calendar?


    Any push in the right direction would be a great help.


    Also this is the HTML code for the calendar boxes on the page.




    So my problem here, is I need the SendKeys function to Act in the calendar box that pops up when "ext-gen1054" and "ext-gen1056" are selected.




    Thanks,
    John

  • Re: Using Sendkeys in IE. VBA code


    SendKeys usually doesn't work with IE automation.


    Rather than trying to control the calendar, have you tried setting the date values directly? Something like:

    Code
    1. Dim startDateElem As Object
    2. 'Get a reference to the start date element, then:
    3. startDateElem.value = Format(Date-1,"dd/mm/yyyy") 'or appropriate date format