Eric F
Eric F

Reputation: 948

Download Excel file from URL

Background

I am attempting to automate the downloading of an Excel file given a URL. I know how to do this, and realize there are many examples for how to do this using either the webbrowser or webclient control however my situation is somewhat different.

Problem

If I simply paste the URL into a normal browser, it will result in asking me to save / open the file like normal. When using the same URL with either the web browser or web client controls, it results in no file. I believe this is because the URL is simply a SharePoint link, that sends a request to get the file, but is not the actual file itself.

This can be done for security reasons or whatever the case is but I was wondering if anyone has ever found a way around this?

Perhaps a way to even just emulate the browser, then emulate clicking save?

The URL for the Excel file does NOT end in .xlsx, it ends in something like:

webclient/zhZZXYRyAaLUgD?TC_file=redirs/viewdataset  

which is why I think the server simply processes the request and then provides the browser the file.

I am attempting to do this in VB.NET but VBA or VB answers seem like they should work as well.

Fiddler Results

enter image description here

Upvotes: 1

Views: 1944

Answers (1)

Eric F
Eric F

Reputation: 948

I seemed to find an easy way to solve my problem. After downloading my file within Internet Explorer, and then viewing my recent downloads, IE has an option if you right click and select "Copy Download Link". This puts the true download URL in the clipboard and actually works using the My.computer.downloadfile method.

Upvotes: 2

Related Questions