Option Explicit
Sub 基本市況報導網站()
Sheets("工作表3").Select
Dim xlVbTable(1 To 2) As Object, R As Integer, C As Integer, i As Variant, Y As Integer
With CreateObject("InternetExplorer.Application")
.Visible = True
.Navigate "http://newmis.twse.com.tw/stock/fibest.jsp?stock=5490"
Application.Wait Now + TimeValue("00:00:02")
Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
Set xlVbTable(1) = .Document.getElementById("hor-minimalist-a")
Set xlVbTable(2) = .Document.getElementById("hor-minimalist-b")
On Error Resume Next
With ActiveSheet
.Cells.Clear
Y = 1
For i = 1 To 2
For R = 0 To xlVbTable(i).Rows.Length - 1
For C = 0 To xlVbTable(i).Rows(R).all.Length - 1
.Cells(Y, C + 1) = xlVbTable(i).Rows(R).Cells(C).innertext
Next
Y = Y + 1
Next
Next
End With
.Quit
End With
End Sub作者: spermbank 時間: 2013-9-6 14:17