+ Reply to Thread
Results 1 to 6 of 6

Issue with downloading > 1 Yahoo stock quotes in 2003 Macro

  1. #1
    Registered User
    Join Date
    12-31-2012
    Location
    Florida
    MS-Off Ver
    Excel 2016 - 365
    Posts
    54

    Issue with downloading > 1 Yahoo stock quotes in 2003 Macro

    I am using Excel 2003

    Hi,
    I looked over some of the threads and did not encounter on of this type. I have been working on an Excel Macro that downloads stock quotes from Yahoo each morning at 7AM. Once the download (1 off 12) has been received the macro copies the first row of stock information and pastes it into the worksheet. I have 12 worksheets, and each contains the download for a single stock. The problem arises after the macro finishes the first worksheet, opens the second worksheet and sends the request to Yahoo for the next stock quote. I then receive an error message that the file is open. Yahoo uses the same file name for each extract (table.csv) and there seems to be an issue with excel closing the table.csv before the next file is received from Yahoo. I have tried to add (Application.Wait Now() + TimeValue("00:10:00")) after the table.csv file is closed to delay proceeding to the opening of the next worksheet and requesting the next stocks download, but that did nothing. Does anyone have any ideas?

    Thanks in advance for any assistance you may be able to offer.
    Don

    Here is a sample part of the Macro:

    Please Login or Register  to view this content.
    Last edited by jeffreybrown; 12-31-2012 at 11:20 PM. Reason: As per Forum Rule #3, please use code tags…Thanks.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Issue with downloading > 1 Yahoo stock quotes in 2003 Macro

    Try something like this (not tested).

    This loops through each worksheet in the sheets array and runs the code between the For-Next block for each sheet.

    Replace ActiveSheet.Name with the 1st worksheet in the DataBase Query and add additional sheet names to the Sheets Array (red).

    If there was additional code at the end of your macro after all the sheets have been updated, you will have to include that after the Next ws line.


    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 12-31-2012 at 11:20 PM.

  3. #3
    Registered User
    Join Date
    12-31-2012
    Location
    Florida
    MS-Off Ver
    Excel 2016 - 365
    Posts
    54

    Re: Issue with downloading > 1 Yahoo stock quotes in 2003 Macro

    Thank you AlphaFrog,
    I added the additional worksheet names and I tried the code, but I still get the '1004' file open error (Table.csv) as the code finishes the first extraction and goes to download the second stock information. What about adding a loop of some kind to delay the process, until the file closes. Maybe a 2 or 3 second time delay just may do it. I am not sure as to what can cause it, as I am running on a QuadCore 64bit machine. Could it be that it is a 64 bit machine, running an older 32 bit software program?

    Thanks
    Don

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Issue with downloading > 1 Yahoo stock quotes in 2003 Macro

    I'm not sure what is causing the problem, but I don't think it's a timing issue or 64-32 bit issue. Can you give a couple of examples of the Hyperlinks for testing?

  5. #5
    Registered User
    Join Date
    12-31-2012
    Location
    Florida
    MS-Off Ver
    Excel 2016 - 365
    Posts
    54

    Re: Issue with downloading > 1 Yahoo stock quotes in 2003 Macro

    I am still alive and kicking... I know it has been some time since you responded, but I can finally get back to trying to work on this auto-update process out.
    Thanks for the above code, but I need for the Yahoo query to match the current ActiveSheet name. So if the active sheet "MET Data" is opened, I need to download the current stock quote data into that "MET Data" worksheet. I am also having an issue with an error message as in the message below. I added the macro to the same spreadsheet that the data will be saved in, to simplify the process.

    Thanks

    Don

    Excel Macro Stock Quote.jpg

    Excel Macro Error - Debug.jpg

  6. #6
    Registered User
    Join Date
    12-31-2012
    Location
    Florida
    MS-Off Ver
    Excel 2016 - 365
    Posts
    54

    Re: Issue with downloading > 1 Yahoo stock quotes in 2003 Macro

    Sorry, I wanted to add the Excel file with the yahoo stock quote data and the macro, but I can not upload an excel file so here is a picture of the worksheet data.
    Don
    Excel Macro Worksheet.jpg

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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