Tables from web to excel
I always use Data - Import External Data - New WebQuery (hope this is the
correct translation)
Record a macro and study the code, you may get sth like this:
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.nordpool.com/marketinfo/elspot/stockholm/elspot.cgi?interval=last8&ccurrency=nok&type=html"
_
, Destination:=Range("W15"))
.Name = "elspot.cgi?interval=last8&ccurrency=nok&type=html "
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "4" '*********HERE IS THE TABLE CHANGE IF
NECESSARY!!!!!
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
End With
HTH
knut
"georgesmailuk" skrev i melding
...
I am able to navigate to a webpage, but wish to copy only one table from
the
page - table(2).
How do i get it from the webpage to excel? I know that the code below
will
make xTable the 2nd table, but how do i get the table to appear in excel
instead of [object]
Dim oResultPage As HTMLDocument
Dim AllTables As IHTMLElementCollection
Dim xTable As IHTMLTable
Set oResultPage = ie.Document
Set AllTables = oResultPage.getElementsByTagName("table")
Set xTable = AllTables.Item(2)
thanks
George
|