ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Downloading stock data (https://www.excelbanter.com/excel-programming/439507-downloading-stock-data.html)

duane

Downloading stock data
 
Help,

The follow code runs great in Windows 2000 and Excel 2000. I can download
data for over 3000 stocks in less than 3 seconds. But it doesnt run at all
in Vista 64 bit and Excel 2007. It errors out
in the €ś .Refresh BackgroundQuery:=True €ś line with a €śRun time error 1004
An unexpected error has occurred€ť message. I wasnt expected it, so I guess
it really is unexpected!

CODE
Set AllStockDataWorksheet = Workbooks(1).Worksheets(2)
Set AllStockDataResults = AllStockDataWorksheet.QueryTables _
.Add(Connection:="URL;http://finance.yahoo.com/d/quotes.csv?s=" &
Left(SymbolString, Len(SymbolString) - 1) & "&f=l1va2&e=.csv", _
Destination:=AllStockDataWorksheet.Cells(RowNumber , 51))

With AllStockDataResults
.Refresh BackgroundQuery:=True
End With

Any help will be appreciated.

Duane




Peter T

Downloading stock data
 
This doesn't look right

.Refresh BackgroundQuery:=True

Comment out BackgroundQuery:=True

Unless you need the query to always constantly update in the background
include
.Refresh BackgroundQuery:=False

Regards,
Peter T

"Duane" wrote in message
...
Help,

The follow code runs great in Windows 2000 and Excel 2000. I can download
data for over 3000 stocks in less than 3 seconds. But it doesn't run at
all
in Vista 64 bit and Excel 2007. It errors out
in the " .Refresh BackgroundQuery:=True " line with a "Run time error 1004
An unexpected error has occurred" message. I wasn't expected it, so I
guess
it really is unexpected!

CODE
Set AllStockDataWorksheet = Workbooks(1).Worksheets(2)
Set AllStockDataResults = AllStockDataWorksheet.QueryTables _
.Add(Connection:="URL;http://finance.yahoo.com/d/quotes.csv?s=" &
Left(SymbolString, Len(SymbolString) - 1) & "&f=l1va2&e=.csv", _
Destination:=AllStockDataWorksheet.Cells(RowNumber , 51))

With AllStockDataResults
.Refresh BackgroundQuery:=True
End With

Any help will be appreciated.

Duane






Don Guillett[_2_]

Downloading stock data
 
If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Duane" wrote in message
...
Help,

The follow code runs great in Windows 2000 and Excel 2000. I can download
data for over 3000 stocks in less than 3 seconds. But it doesnt run at
all
in Vista 64 bit and Excel 2007. It errors out
in the €ś .Refresh BackgroundQuery:=True €ś line with a €śRun time error 1004
An unexpected error has occurred€ť message. I wasnt expected it, so I
guess
it really is unexpected!

CODE
Set AllStockDataWorksheet = Workbooks(1).Worksheets(2)
Set AllStockDataResults = AllStockDataWorksheet.QueryTables _
.Add(Connection:="URL;http://finance.yahoo.com/d/quotes.csv?s=" &
Left(SymbolString, Len(SymbolString) - 1) & "&f=l1va2&e=.csv", _
Destination:=AllStockDataWorksheet.Cells(RowNumber , 51))

With AllStockDataResults
.Refresh BackgroundQuery:=True
End With

Any help will be appreciated.

Duane






All times are GMT +1. The time now is 08:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com