Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50099

Issue with downloading > 1 Yahoo stock quotes in 2003 Macro

$
0
0
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:

Sub ALL_IN_ONE_UPDATE()
'
' ALL_IN_ONE_UPDATE Macro
' Macro recorded 12/28/2012 by Don
'

'
Workbooks.Open Filename:= _
"C:\My Documents\Don's\YAHOO Stock Database Query (Version 10).xls"
Rows("8:8").Select
Selection.Insert Shift:=xlDown
Range("B4:C4").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Workbooks.Open Filename:= _
"http://ichart.finance.yahoo.com/table.csv?s=hxm&d=12&e=31&f=2012&g=d&a=0&b=1&c=2007&ignor=.csv"
ActiveWindow.Visible = False
Windows("table.csv").Visible = True
Range("A2:G2").Select
Selection.Copy
ActiveWindow.Close
Range("A8").Select
ActiveSheet.Paste
Range("I9:U9").Select
Selection.AutoFill Destination:=Range("I8:U9"), Type:=xlFillDefault
Range("I8:U9").Select
Sheets("MET Data").Select
Rows("8:8").Select
Selection.Insert Shift:=xlDown
Range("B4:C4").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Workbooks.Open Filename:= _
"http://ichart.finance.yahoo.com/table.csv?s=met&d=12&e=31&f=2012&g=d&a=0&b=1&c=2007&ignor=.csv"
ActiveWindow.Visible = False
Windows("table.csv").Visible = True
Range("A2:G2").Select
Selection.Copy
ActiveWindow.Close
Range("A8").Select
ActiveSheet.Paste
Range("I9:U9").Select
Selection.AutoFill Destination:=Range("I8:U9"), Type:=xlFillDefault
Range("I8:U9").Select
Sheets("FIO Data").Select
Rows("8:8").Select
Selection.Insert Shift:=xlDown
Range("B4:C4").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
Workbooks.Open Filename:= _
"http://ichart.finance.yahoo.com/table.csv?s=fio&d=12&e=31&f=2012&g=d&a=0&b=1&c=2007&ignor=.csv"
ActiveWindow.Visible = False
Windows("table.csv").Visible = True
Range("A2:G2").Select
Selection.Copy
ActiveWindow.Close
Range("A8").Select
ActiveSheet.Paste
Range("I9:U9").Select
Selection.AutoFill Destination:=Range("I8:U9"), Type:=xlFillDefault
Range("I8:U9").Select
.
.
.

Viewing all articles
Browse latest Browse all 50099

Trending Articles