+ Reply to Thread
Results 1 to 10 of 10

Open file downloaded by a non-file URL

  1. #1
    Registered User
    Join Date
    01-30-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    8

    Open file downloaded by a non-file URL

    I am using VBA to execute a URL to download a file from a website. The problem I have is caused by the fact that the URL is not a link to a file, but it is similar to the following link that one uses to download Firefox:
    Please Login or Register  to view this content.
    As you can see, this URL does not mention ".exe", but it downloads a .exe file anyway. I am using:
    Please Login or Register  to view this content.
    to cause the file to download, and my default browser is IE.

    Anyway, the file download is initiated as I require, but IE opens the "Open, Save, Cancel" dialogue box and I don't know how to get my VBA to interact with it. Ideally I would like to Open the file (the one I am downloaded is an .xls file), but I don't know how to proceed from there. Perhaps there is an argument I can pass to explorer.exe to force the open?

    Alternatively, if I set my default browser to Chrome then the file is automatically downloaded (no dialogue box), but there is no easy way for me to determine the file name (because the script on the website creates a new file name every time). If there is a way to determine the file name I could use that approach instead.

    Can anyone help please?

    [Incidentally, I am actually downloading a report from Salesforce.com, and I have used their Connect for Office Excel pulig-in successfully in the past, but the company I work for has implemented security that does not allow me access with this plug-in over VPN, even though I can access the report manually via the website over VPN; so if anyone has any specific suggestions there I would welcome them!]

    Many thanks

  2. #2
    Registered User
    Join Date
    03-30-2014
    Location
    Suzhou,China
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Open file downloaded by a non-file URL

    Hi whizzdome,
    See if help you:

    Please Login or Register  to view this content.
    Welcome to China,Welcome to Suzhou...And,我是来学英文的。

  3. #3
    Registered User
    Join Date
    01-30-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Open file downloaded by a non-file URL

    Thank you so much @wcymiss for your solution -- it works perfectly for the Firefox example, and I will add this code to my set of tools.

    Unfortunately it does not work for my particular problem -- I guess there is something slightly different for my download. The code fails at the line "strUrl = .getresponseheader("Location")", saying "Run-time error '-2147012746 (80072f76)': The requested header was not found" That is such a shame -- but do you know what might be the problem? I will try to find a publically-acessible link that demonstrates the same problem and we can try from there.

    Thanks again.

  4. #4
    Registered User
    Join Date
    01-30-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Open file downloaded by a non-file URL

    Quick extra note: I did change the "FF.exe" to "SF.xls" because that is the file type of the download, but I don't think it even got far enough to use that.

  5. #5
    Registered User
    Join Date
    01-30-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Open file downloaded by a non-file URL

    Right, here's another example that fails in the same way, and which you can try:
    Please Login or Register  to view this content.
    This is to download an exe file to install a key generator from Softpedia. This fails with the same "Run-time error" looking for the .getresponseheader.

    I feel we are so very close to the answer !

    Any ideas please?
    Last edited by whizzdome; 04-05-2014 at 12:15 PM.

  6. #6
    Registered User
    Join Date
    03-30-2014
    Location
    Suzhou,China
    MS-Off Ver
    Excel 2003
    Posts
    41
    when the website will redirect a new url,it has a location header in its HTTP response headers. the firefox downloading url is an example for this.

    would you mind useing the software fiddler?. it can log all HTTP(s) traffic between your computer and the Internet.then you can get the actual url of the downloading website.
    Last edited by wcymiss; 04-05-2014 at 12:57 PM.

  7. #7
    Registered User
    Join Date
    01-30-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Open file downloaded by a non-file URL

    Thanks for the suggestion, I will try that and report back.

  8. #8
    Registered User
    Join Date
    01-30-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Open file downloaded by a non-file URL

    Sorry, I couldn't get Fiddler to work. I'm afraid I couldn't understand the configuration options in Fiddler, and when I tried the change anything (according to the instructions in the Fiddler website) either Windows or my browser warned me that there were security issues, and I didn't feel safe continuing. I do know that when I navigated in my browser it caused activity in Fiddler, but when I ran the code from earlier in this post nothing appeared to happen in Fiddler.

  9. #9
    Registered User
    Join Date
    03-30-2014
    Location
    Suzhou,China
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Open file downloaded by a non-file URL

    the download url is in the source of the webpage http://www.softpedia.com/dyn-postdow...194939&t=4&i=1
    Please Login or Register  to view this content.
    you can try this code:

    Please Login or Register  to view this content.
    <meta http-equiv="refresh" content="3; url="...."> will direct to a new url after "3.
    Last edited by wcymiss; 04-05-2014 at 11:22 PM.

  10. #10
    Registered User
    Join Date
    01-30-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Open file downloaded by a non-file URL

    Thank you so much for pursuing this. Your suggestion for Softpedia works really well, but there are still problems with the Salesforce link -- perhaps I need to use the work laptop. I will try that when I start work again and let you know how I get on.

    Thanks again, I have learnt a lot!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Downloaded Excel file taking long time to open
    By Nanjunda in forum Excel General
    Replies: 1
    Last Post: 11-14-2013, 09:10 AM
  2. Open 2nd file(CSV) from cell reference, copy columns to main file & close 2nd file
    By Langchop in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2013, 05:09 AM
  3. Not able to open downloaded excel file in 2007
    By narendrabr in forum Excel General
    Replies: 6
    Last Post: 10-17-2012, 03:11 AM
  4. [SOLVED] open variably named file, copy/paste data into consolidation file, open next file in list
    By sllawrence1968 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-29-2012, 09:49 PM
  5. Replies: 5
    Last Post: 11-12-2005, 09:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1