LinneaUD13
New Member
- Joined
- Jun 5, 2009
- Messages
- 5
The company I work for has a lot of intranet sites that require a form to be filled out and then the user hits the submit button which then opens a file. Up until now I have been able to use the HTML code to write a line of vba code that opens the file without prompts
"from_date" and "to_date" are the html input names in the form and "data/dataitems" is the action of the form.
I have a new site that starts to open the file but then says it can't open the site when I ty to string together the HTML fields.
The HTML has code that I haven't seen in any of the other sites.
The action for this form is "generateReport.action"
Could this be preventing me from opening the file and does anyone know a workaround. I know how to submit the form but then I get stuck at the File Download prompt and I don't want to use send keys.
I am currently using Excel 2010 with Windows 7
Thanks in advance for any suggestions
Code:
Workbooks.Open Filename:="https://urlStr1.urlStr2.com/data/dataitems?from_date=11%2001%202010&to_date=11%2002%2010"
I have a new site that starts to open the file but then says it can't open the site when I ty to string together the HTML fields.
The HTML has code that I haven't seen in any of the other sites.
HTML:
on click= "return dateValidator();"
$(document).ready(function() {
$("#startDatePicker").datepicker();
$("#endDatePicker").datepicker();
});
function dateValidator() {
var startDate = $("#startDatePicker").val();
var endDate = $("#endDatePicker").val();
// Check if any date is not null
if (startDate == null || endDate == null || "" == startDate || "" == endDate) {
alert("Either startDate or endDate is empty");
return false;
}
// (endDate > startDate) && (endDate < startDate + 30)
if ((Date.parse(startDate) > Date.parse(endDate))) {
alert("End Date [" + endDate + "]should be greater than Start Date [" + startDate + "]");
return false;
}
var parsedStartDate = Date.parse(startDate);
var parsedEndDate = Date.parse(endDate);
var difference = (parsedEndDate - parsedStartDate) / (86400000);
if (difference > 30) {
alert("Difference between endDate and startDate can not be more than 30 days");
return false;
}
return true;
}
The action for this form is "generateReport.action"
Could this be preventing me from opening the file and does anyone know a workaround. I know how to submit the form but then I get stuck at the File Download prompt and I don't want to use send keys.
I am currently using Excel 2010 with Windows 7
Thanks in advance for any suggestions