+ Reply to Thread
Results 1 to 5 of 5

Download and Paste CSV File into Worksheet, Using Ajax URL?

  1. #1
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    202

    Download and Paste CSV File into Worksheet, Using Ajax URL?

    I'd like to use VBA to automatically download a CSV file and paste it into an existing worksheet, however the file I want to download is Morningstar Key Ratios data, which is normally accessed via an "Export" button on their website. The "Export" button apparently accesses an "ajax" URL (if that's the right terminology for it!?):

    http://financials.morningstar.com/aj...cur=&order=asc

    This URL (if I simply paste it into a browser) automatically downloads the CSV file (to my Downloads folder). But I don't want/need to save the CSV file; I would like VBA to "intercept" it and paste it into an existing worksheet (in the open workbook that is running the VBA macro). I tried URLDownloadToFile but (since this URL is an HTML page rather than a direct link to a CSV file, I'm guessing) it doesn't work.

    So, what is the simplest way (given an "ajax" URL that downloads a CSV file) to download the data and get it pasted into my worksheet? Thanks for any help!

  2. #2
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Download and Paste CSV File into Worksheet, Using Ajax URL?

    Here you go:

    Please Login or Register  to view this content.
    Please click the * below if this helps (as noone gets paid on this forum)
    Please click the * below if this helps

  3. #3
    Registered User
    Join Date
    04-30-2007
    Posts
    26

    Re: Download and Paste CSV File into Worksheet, Using Ajax URL?

    Hi,

    Thanks,


    Sathish
    Last edited by sathis; 07-11-2015 at 06:30 AM.

  4. #4
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    202

    Re: Download and Paste CSV File into Worksheet, Using Ajax URL?

    JasperD, just now tried this and I am getting an error. Here is how I set up the first part of my macro (trying to download data for GE as a test):

    Please Login or Register  to view this content.
    When I run the macro, it gets to the .Send line and then generates this error message:
    Run-time error '-2147012889 (80072ee7)':
    The server name or address could not be resolved

    I have the reference for Microsoft WinHTTP 5.1 checked under Tools, References within VBA. If I paste my URLString3 directly into a browser, it downloads the file just fine. What am I doing wrong?

    Probably something simple and obvious, but I am too uneducated in VBA to know what it is!

  5. #5
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Download and Paste CSV File into Worksheet, Using Ajax URL?

    Works fine for me. You don't need the reference. You also don't need .WaitForResponse, but that doesn't cause the error
    I can't replicate your problem, so not sure how to help you.

+ 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. [SOLVED] File Download Name assuming Thread Title as File Name Windows 2007
    By jaslake in forum Suggestions for Improvement
    Replies: 10
    Last Post: 03-19-2014, 01:07 PM
  2. Macro to Download csv file from a dynamic date based url to a specified file location
    By srimani202002 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2014, 07:17 AM
  3. How to import data from webpage (from ajax)
    By Excellearner2012 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-23-2012, 03:39 PM
  4. Web site interaction vba/ajax
    By tamg28 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-26-2011, 11:13 PM
  5. AJAX combo box in excel
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-20-2006, 05:50 AM

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