PDA

View Full Version : File download without knowing the full url / redirect



tho
08-13-2008, 12:44 PM
Hi hi, I have searched a lot and now that maybe some of you guys can help me. (This is not directly a Excel vba question but I would like to use the functionality in Excel.) have a link such as /downloadfile?file=12345. When opening this link in a browser the DownloadFile window popups and the file can be downloaded. I would like to be able to download the file without involving the DownloadFile pop up (since some users have auto open enabled thus the downloadfile pop-up is not always shown). I have tried URLDownloadToCacheFile and similiar methods but they fail as they dont have the direct link to the file. So my question now is how can I extract the direct url ? There should be a way to capture it since it will be used in the downloadfile dialog. Thanks in advance

Kenneth Hobs
08-13-2008, 02:12 PM
You will need to give the url and the route to get a file. Also, please post what you have tried.

tho
08-14-2008, 12:05 AM
Hi,
I have the complete url (let's call it url 1) to the script file that redirects and initiates the download. The script itself is hidden so I cannot see the path to the file I wish to download this way.


What I have tried:
- use findwindow and sendkey and postmessage
(this work and I can download by clicking the buttons needed via vba, but only if the auto open in the browser is not enabled. If the user has this functionality enabled then the FileDownload Dialog is not shown, and the file I wish to download is opened in the browser instead)

- methods such as DownloadFileFromUrl , DoFileDownload, …
(problem here is that I will download the htm(l) file displayed by the script (at url 1) and not the file I wish to download. These methods download the file they find at a specific url and do not wait for redirect. So this does not work for me.

-querytable in excel with url 1 as source
Problem here is that also the redirect is not working and I will import the html text displayed by the script (at url 1)


Since the browser can either save or open the file at some point, the direct path to the file should be "fetchable" and or to the temporary file that was created.





Here is how the url looks: url 1 (url within our IntraNet)
url:7030/DoStuff/download_file_inline?file_name=Data.xls&file_handle_name=MTIObjectHandle-0002-1~R~siniypkprdwebKI------F2U~ExcelSht~KI~~