Results 1 to 7 of 7

AlphaVantage Quote Retrieval

Threaded View

  1. #1
    Registered User
    Join Date
    11-06-2017
    Location
    Florida
    MS-Off Ver
    2007
    Posts
    15

    AlphaVantage Quote Retrieval

    So I'm trying to pull closing stock quotes from Alpha Vantage which seems pretty simple. They provide nice API examples. The problem is that my VBA code fails with:

    VBAErrorMsg.png

    Cut down to a minimum toy example the code below is what I'm trying to do. You'll note that for debug purposes, at one point I save my "qurl" query out to the query sheet. And if I copy/paste that URL into a web browser it works fine so I'm assuming there is no problem in the URL itself, but with the VBA call for the data. Yet the code always crashes pointing to the "Refresh" line. (Changing it to "true" doesn't help - that keeps it from crashing but it spins its wheels indefinitely then.)

    Any suggestions to make this run? Thanks.

    Bill

    Sub AlphaCurrentQuote(Symb As String, AdjCloseQ As Single)
    'Retrieve the current closing quote from Alpha Vantage
        Dim APIkey      As String
        Dim QuerySht    As Worksheet
        Dim DataSht     As Worksheet
        Dim qurl        As String
        
        Set DataSht = ActiveSheet
        Set QuerySht = Sheets.Add
        APIkey = Range("Notes!C2")
        
        qurl = "http://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=" & Symb & _
                "&outputsize=compact&apikey=" & APIkey & "&datatype=csv"
                
        QuerySht.Cells(1, "K") = qurl        'Debug info: Save the url for examination
                
        With ActiveSheet.QueryTables.Add(Connection:="URL;" & qurl, Destination:=QuerySht.Range("A1"))
            .BackgroundQuery = True     
            .TablesOnlyFromHTML = False
            .Refresh BackgroundQuery:=False  
            .SaveData = True
        End With
    Last edited by Thales42; 11-07-2017 at 12:20 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Code to save form as a specific name based on value in cell
    By bduncan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-17-2017, 02:33 PM
  2. Replies: 1
    Last Post: 07-14-2016, 02:23 PM
  3. [SOLVED] How to find and replace hidden single quote ? (This sign is single quote: ')
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-19-2014, 03:48 PM
  4. Conditional Retrieval
    By okl in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-07-2010, 09:05 AM
  5. ESSBASE Retrieval using VBA
    By okelly in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-06-2007, 10:33 AM
  6. MAC Retrieval
    By sparx in forum Excel General
    Replies: 0
    Last Post: 03-19-2006, 04:51 PM
  7. Data Retrieval
    By bach in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-08-2005, 10:43 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