0

I am trying to write an application that will download .csv and .xls files and save them into a folder that will be accessed later by a VBA macro. I am posting this question after the unsuccessful use of the solution in the following link: How do i download a file using VBA (Without internet explorer)

The macro runs successfully, but the downloaded .csv file only contains the html from the login page. I find that strange because when I copy and paste the link directly into the browser without logging in, I am immediately prompted with a save, open, close window for the file.

As much as possible I am trying to avoid using SendKeys, but I can't seem to find another solution that works. I am not opposed to options other than VBA. Any help would be appreciated, thank you.

Community
  • 1
  • 1
Seraphim
  • 171
  • 1
  • 12

1 Answers1

1

Your browser stores cookies which likely allows you to login automatically. Try browsing the page in different tabs in an incognito browser and you'll likely have to login each time.

You'll have to find a way to make the same requests your browser is sending to login, and use the cookies stored to make the requests to download the files.

Hello
  • 26
  • 2
  • I see, I tried what you said and found that I do have to login everytime. What do you think could be a workaround to get the files downloaded? – Seraphim Jan 25 '17 at 19:08
  • You'll have to make the same requests your browser is sending. Open your browsers dev tools and look at the network tab for the requests being sent. Mostly likely your browser is sending a POST request for the login form. Search around for how to make POST requests and managing cookies. – Hello Jan 25 '17 at 19:44