Option Explicit
Sub goodinfo()
Dim A As Object, i As Integer, C As Variant, Sh As Worksheet, Stock As String
Do
Stock = InputBox("輸入股票代號", "股票代號", 2303)
Loop Until Len(Stock) >= 4
Set Sh = ActiveSheet '可指定工作表
With CreateObject("InternetExplorer.application")
.Navigate "http://www.goodinfo.tw/stockinfo/ShowK_ChartFlow.asp?RPT_CAT=DR_3M&STOCK_ID=" & Stock & "&CHT_CAT=MONTH"
.Visible = True
Do While .Busy Or .ReadyState <> 4
DoEvents
Loop
Sh.Cells.Clear
Set A = .Document.getelementsbytagname("table")(0)
For i = 0 To A.Rows.Length - 1
For C = 0 To A.Rows(i).Cells.Length - 1
ActiveSheet.Cells(i + 1, C + 1) = A.Rows(i).Cells(C).innertext
Next
Next
Set A = .Document.getelementbyid("content")
For i = 0 To A.Rows.Length - 1
For C = 0 To A.Rows(i).Cells.Length - 1
ActiveSheet.Cells(i + 4, C + 1) = A.Rows(i).Cells(C).innertext
Next
Next
Sh.UsedRange.EntireColumn.AutoFit
.Quit
End With
MsgBox "OK"
End Sub作者: chickout2 時間: 2016-5-31 00:35