LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Code to get data from Yahoo Finance

Can anybody tell me why I can't get the sendkey to work in this code. I put
the Stock symbol in the Active worksheet in cell A1. I just can't get the
file saved properly.


Sub GetStocks()
Const READYSTATE_LOADING = 1
Folder = "c:\Temp\"
URL1 = "http://ichart.finance.yahoo.com/table.csv?s="
URL2 = "&a=12&b=01&c=2007&d=01&e=01&f=2009&g=m&ignore=.cs v"

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

RowCount = 1
Do While Range("A" & RowCount) < ""
Stock = Range("A" & RowCount)
On Error Resume Next
Kill (Folder & Stock & ".csv")
On Error GoTo 0
'get web page
IE.Navigate2 URL1 & Stock & URL2
Do While IE.readystate < READYSTATE_LOADING
DoEvents
Loop

'Loop
Application.Wait (Now + TimeValue("0:00:05"))
AppActivate "File Download", True

'Alt S - Save File
Application.SendKeys "%S", True
'Alt n - Enter filename
Application.SendKeys "%n", True
Application.SendKeys _
(Folder & Stock & ".csv{ENTER}"), True



RowCount = RowCount + 1
Loop


End Sub

"Charles L. Snyder" wrote:


This retired EE Prof has hundreds of excel spreadsheets, all freely
downloadable, that will do what you want and mo

http://www.gummy-stuff.org/

cls

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import from finance.yahoo.com ryguy7272 Excel Programming 10 March 20th 07 08:59 PM
Web queries & Yahoo! Finance cwhaley Excel Discussion (Misc queries) 1 February 2nd 06 12:31 AM
Sort CSV file from Yahoo Finance Query Jon Excel Programming 1 October 7th 05 07:16 AM
Historical Stock Quotes - Yahoo Finance Jason Excel Programming 4 July 4th 05 12:40 AM
vba yahoo! finance Arun Ram Kumaran Excel Programming 1 July 25th 03 01:04 AM


All times are GMT +1. The time now is 03:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"