- 帖子
- 766
- 主題
- 256
- 精華
- 0
- 積分
- 1035
- 點名
- 0
- 作業系統
- windows 11
- 軟體版本
- OFFICE2021
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2011-5-30
- 最後登錄
- 2026-10-2
|
直接抓除息表到工作表中不正常
股票名稱不正常
Sub 寶來除息表()
Application.ScreenUpdating = False '除權除息表
Application.EnableEvents = False
Application.DisplayStatusBar = False
ActiveSheet.DisplayPageBreaks = False
Dim i As Integer, S As Integer, k As Integer, j As Integer
Dim Element
With CreateObject("InternetExplorer.Application")
' .Visible = True '可顯示網頁
.Navigate "http://jdata.yuanta.com.tw/z/ze/zeb/zeb.djhtm"
Do While .Busy Or .readyState <> 4: DoEvents: Loop
Set Element = .Document.getElementsByTagName("table")
On Error Resume Next
Sheets("sheet1").Range("a:e").ClearContents
With Sheets("sheet1")
For S = 2 To 2 '已找出網頁的table內容在 0-3 中
For i = 1 To Element(S).Rows.Length - 1
k = k + 1
For j = 0 To 4 '資料的欄位共6位
.Cells(k, j + 1) = Element(S).Rows(i).Cells(j).innerText
Next
Next
Next
End With
.Quit
End With
Set Element = Nothing
Application.DisplayStatusBar = True
End Sub
Book2.rar (20.52 KB)
|
|