VBA - open file by submitting internet form

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

Code:
Workbooks.Open Filename:="https://urlStr1.urlStr2.com/data/dataitems?from_date=11%2001%202010&to_date=11%2002%2010"
"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.
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
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top