- 帖子
- 2035
- 主題
- 24
- 精華
- 0
- 積分
- 2031
- 點名
- 0
- 作業系統
- Win7
- 軟體版本
- Office2010
- 閱讀權限
- 100
- 性別
- 男
- 註冊時間
- 2012-3-22
- 最後登錄
- 2024-2-1
|
66#
發表於 2013-11-22 07:24
| 只看該作者
本帖最後由 c_c_lai 於 2013-11-22 07:36 編輯
回復 60# GBKEE
(圖中 與54# 的程式碼有點不樣)
附上執行之程式碼:- Sub 鉅享網4()
- Dim URL As String, shts As Worksheet
- Dim x As Variant, xi As Integer, A As Object, xlHtm
- Set shts = ActiveSheet ' '("工作表2")
- shts.Cells.Clear
- URL = "http://www.cnyes.com/twstock/Institutional/1101.htm"
- With CreateObject("InternetExplorer.Application")
- .Visible = True ' 是否顯示 IE
- .Navigate URL
- Do While .ReadyState <> 4 Or .Busy
- DoEvents
- Loop
- For Each x In .Document.getElementsBytagname("input")
- If x.Value = "查詢" Then x.Click: Exit For
- Next
- Do While .ReadyState <> 4 Or .Busy: DoEvents: Loop
- xlHtm = .Document.body.innerHTML '儲存
- Set A = .Document.getElementsBytagname("table")
- For xi = 1 To 6
- .Document.body.innerHTML = A(xi).outerHTML
- .ExecWB 17, 2 ' Select All
- .ExecWB 12, 2 ' Copy selection
- With shts
- .Range("A" & .[A65535].End(xlUp).Row + 1).Select
- .PasteSpecial Format:="HTML"
- End With
- .Document.body.innerHTML = xlHtm '還原
- Next xi
- shts.Cells.EntireColumn.AutoFit ' 自動調整欄寬
- .Quit
- End With
- End Sub
複製代碼
P.S. 這是剛才才執行出來的決果。 |
|