返回列表 上一主題 發帖

直接抓除息表到工作表中不正常

  1. Sub 寶來除息表()
  2. Application.ScreenUpdating = False   '除權除息表
  3. Application.EnableEvents = False
  4. Application.DisplayStatusBar = False
  5. ActiveSheet.DisplayPageBreaks = False
  6.     Dim i As Integer, S As Integer, k As Integer, j As Integer
  7.     Dim Element
  8.       With CreateObject("InternetExplorer.Application")
  9.         '.Visible = True           '可顯示網頁
  10.        .Navigate "http://jdata.yuanta.com.tw/z/ze/zeb/zeb.djhtm"
  11.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  12.         Set Element = .Document.getElementsByTagName("table")(2) ' 已找出網頁的table內容在 0-3 中
  13.         Sheets("sheet1").Cells.ClearContents
  14.         With Sheets("sheet1")
  15.             For i = 1 To Element.Rows.Length - 1
  16.                 For j = 0 To Element.Rows(i).Cells.Length - 1
  17.                     If j = 0 And i > 2 Then
  18.                         .Cells(i, j + 1) = Element.all.tags("a")(i - 3).innertext
  19.                     Else
  20.                         .Cells(i, j + 1) = Element.Rows(i).Cells(j).innertext
  21.                     End If
  22.                 Next
  23.             Next
  24.         End With
  25.        .Quit
  26.     End With
  27.     Set Element = Nothing
  28.    
  29. Application.DisplayStatusBar = True
  30. End Sub
複製代碼
回復 1# t8899
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

        靜思自在 : 君子如水,隨方就圓,無處不自在。
返回列表 上一主題