|
-
Feb 20th, 2007, 12:47 PM
#1
Thread Starter
Hyperactive Member
Need help with Excel web query
I've used a procedure to pull stock price historical data from Yahoo. Yahoo has changed something and now the procedure will not work. With a worksheet named 'Web Data' I execute the following. On occasion, data does get to the worksheet, but most of the time (and I cannot figure out why) I get an error stating that "The file could not be accessed ...", and then "Invalid Web Query". Here is the code that I am using:
'e.g. pull Dow Jones data for Feb 14 thru Feb 15.
smo = 2 ' Feb
sda = 14 ' 14
syr = 7 ' 2007
emo = 2 ' Feb
eda = 15 ' 15
eyr = 7 ' 2007
fund = "^DJI"
Sheets("Web Data").Activate
Range("a1").Select
Selection.Clear
With Selection.QueryTable
.Connection = _
"URL;http://finance.yahoo.com/q/hp?&a=" & smo - 1 & "&b=" & sda & "&c=" & syr _
& "&d=" & emo - 1 & "&e=" & eda & "&f=" & eyr & "&g=d&s=" & fund
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.Refresh
End With
The url for this, which works under Internet Explorer, is:
http://finance.yahoo.com/q/hp?&a=1&b=14&c=7&d=1&e=15&f=7&g=d&s=^DJI
I think the '?' is causing the problem but don't understand why it is intermittent or how I can get around it.
Any help will be much appreciated. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|