PDA

View Full Version : Automatic download



Tenspeed39355
03-11-2006, 08:08 AM
Good morning guys. This is a long shot but here goes. Is ther a way to automaticly go to a web page once a day and do a copy and download the data from that web page into Excel? If so please let me know and if you guys do not do that where can I go to get the information. Thanks
Max

mdmackillop
03-11-2006, 08:17 AM
The following will get data from a web table. An on-time macro would automate this. A bit of tweaking will I'm sure, get the whole page.
Regards
MD


Sub gethtmltable()
Dim objWeb As QueryTable

With Sheets("Sheet1")
.Range("A:C").ClearContents
Set objWeb = .QueryTables.Add( _
Connection:="URL;http://www.vbaexpress.com/kb/kblist.php", _
Destination:=.Range("A1"))
With objWeb
.WebSelectionType = xlSpecifiedTables
.WebTables = "12" ' Identify your HTML Table here
.Refresh BackgroundQuery:=False
.SaveData = True
End With
.Range("B1").ColumnWidth = 30
.Range("C1").ColumnWidth = 40
.Columns("B").Font.ColorIndex = 5
.Columns("B").Font.Underline = xlUnderlineStyleSingle
End With
Set objWeb = Nothing
End Sub

Cyberdude
03-11-2006, 02:03 PM
Hey. Malcolm, looks neat ... except I don't understand it.

With objWeb
.WebSelectionType = xlSpecifiedTables
.WebTables = "12" ' Identify your HTML Table here
.Refresh BackgroundQuery:=False
.SaveData = True
End With Can you explain the red ("WebTables") line a bit. Five days a week I manually download stock data in each of 4 tables from Yahoo financial by clicking on THEIR "download data to spreadsheet" button to do it. So my question is: how do I identify their table? :reading:

mdmackillop
03-11-2006, 03:44 PM
Hi Sid
I think it was Matt (MVidas) who came up with the clever bits here. I'm just standing on the shoulders of giants!
I would just set up a loop and see what results.
Regards
Malcolm

stanl
03-11-2006, 04:37 PM
Check out

http://www.microsoft.com/downloads/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en

tells you everything you need about a webpage.
Stan