Hi Experts,
Iam working on a project ''Automation IE'' need help on the same.
I am trying to spool one excel report from website by giving From date and To Date are as inputs iam able to give enter dates with my code but iam unable click on generate button.. Any help greatly appreciated.
Below is the HTML source code for from & To dates
Below is the HTML source code for Export Report ButtonHTML Code:<input name="ctl00$ContentPlaceHolder1$txt_0" type="text" maxlength="10" id="txt_0" tabindex="1"class="watermarked" width="200px" selectionstart="txt_0" onchange="isDate2(this)" style="width: 200px;Height:20px;" autocomplete="off"> <input name="ctl00$ContentPlaceHolder1$txt_1" type="text" maxlength="10" id="txt_1" tabindex="2"class="watermarked" width="200px" selectionstart="txt_1" onchange="isDate2(this)" style="width: 200px;Height:20px;" autocomplete="off">
And this is Function codeHTML Code:<input type="submit" name="ctl00$ContentPlaceHolder1$btnExportXLS" value="Export Report" onclick="if(!Validate()) return false;" id="btnExportXLS" tabindex="3"class="button blue" onmousedown="return isTxtwithfocus(event, this)" style="width:101px;float: none; margin-top: 2px;">
HTML Code:function ValidateForm(src){ assignvalue() var src1 = document.getElementById("txt"+ src); if(src1.value !='') { if(isDate2(src1.value,"txt_"+ src)==false){ returnfalse } returntrue} }
This is my VBA code- Last two lines for click export button
Sub User_Wise_Productivity() Dim From_Date AsString Dim To_Date AsString From_Date = InputBox("Enter report From date in (Ex: DD.MM.yyy)format") To_Date = InputBox("Enter report To date in (Ex: DD.MM.yyy)format") Set browser = CreateObject("internetexplorer.application") browser.Visible =True browser.navigate ("My URL") Do DoEvents Loop Until browser.readyState =4 browser.document.getElementById("txtUserName").Value ="Myid" browser.document.getElementById("txtPassword").Value =“Mypsw” browser.document.getElementById("selFund").selectedIndex ="21" browser.document.getElementById("btnSubmit").Click Do DoEvents Loop Until browser.readyState <>4 browser.navigate ("MY URL Page2") Do DoEvents Loop Until browser.readyState <>4 Dim reprt AsString reprt ="11" With browser Set Post =.document.getElementById("ddlrptlist") ForEach elem In Post.getElementsByTagName("option") If elem.Value = reprt Then elem.Selected =True:ExitFor Next elem .document.getElementById("ddlrptlist").FireEvent ("onchange") EndWith Do DoEvents Loop Until browser.readyState <>4 browser.document.getElementById("txt_0").Value = From_Date browser.document.getElementById("txt_1").Value = To_Date Application.Wait (Now + TimeValue("0:00:02")) browser.document.getElementById("btnExportXLS").Focus browser.document.getElementById("btnExportXLS").Click End Sub



Reply With Quote
