- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
本帖最後由 GBKEE 於 2016-4-26 10:25 編輯
回復 9# BigDog
2016/4/26 更新- Option Explicit
- Sub 鉅亨網_董監持股()
- Dim ie As Object, A As Object, T As Date, i As Integer, c As Integer
- Dim Code As String, xMonth As String
- Code = InputBox("輸入股票代號 : ", "股票代號", 2303)
- xMonth = InputBox("輸入年月 : ", "年月", Format(DateAdd("M", -2, Date), "yyyy年m月"))
- Set ie = CreateObject("InternetExplorer.Application")
- ie.Navigate "http://www.cnyes.com/twstock/directorholder/" & Code & ".htm"
- ' ie.Visible = True
- Do While ie.Busy Or ie.ReadyState <> 4: DoEvents: Loop
- With ie.Document
- With .getElementById("ctl00_ContentPlaceHolder1_DropDownList1")
- .Value = xMonth
- .fireEvent ("onchange")
- End With
- Do While ie.Busy Or ie.ReadyState <> 4
- DoEvents
- Loop
- On Error Resume Next
- Do
- DoEvents
- Set A = .getelementsbytagname("table")(1)
- If Not A Is Nothing Then
- If InStr(A.innertext, Format(xMonth, "YYYYM")) Then
- If Err Then
- Debug.Print Err
- Err.Clear
- Else
- Exit Do
- End If
- End If
- End If
- Loop
- On Error GoTo 0
- Cells.Clear
- Cells(1, "A").Resize(, 4) = Array("股票代號", Code, "月份", xMonth)
- For i = 0 To A.Rows.Length - 1
- For c = 0 To A.Rows(i).Cells.Length - 1
- Cells(i + 2, c + 1) = A.Rows(i).Cells(c).innertext
- Next
- Next
- End With
- ie.Quit
- MsgBox "OK"
- End Sub
複製代碼 |
|