返回列表 上一主題 發帖

[發問] 公開資訊觀測站的代號如何透過程式自動輸入?

[發問] 公開資訊觀測站的代號如何透過程式自動輸入?

公開資訊觀測站

請問各位大大
這個網址的公司代碼或簡稱
如何透過IE控制的方式輸入?

已經找到該id="co_id"
但輸入value他就是不理我...= =

有大大知道要如何用嗎?
PKKO

  1. Sub 巨集1()
  2. Cells.Clear

  3.     With ActiveSheet.QueryTables.Add(Connection:= _
  4.         "URL;https://mops.twse.com.tw/mops/web/ajax_t05st10_ifrs?encodeURIComponent=1&firstin=1&off=1&queryName=co_id&isnew=true&co_id=1101", Destination:=Range("$A$1"))
  5.         .WebTables = "4"
  6.         .Refresh BackgroundQuery:=False
  7.         .Delete
  8.     End With
  9. End Sub
複製代碼
回復 1# PKKO

TOP

回復 2# PKKO
試試看
  1. Option Explicit
  2. Sub Ex()
  3.     Dim E As Object, T As Date, R As Integer, C As Integer
  4.     With CreateObject("InternetExplorer.Application")
  5.         .Visible = True
  6.         .Navigate "https://mops.twse.com.tw/mops/web/t05st10_ifrs"
  7.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  8.        ' .Document.GETELEMENTBYID("co_id").Value = "2317"
  9.         For Each E In .Document.all.tags("INPUT")
  10.             If E.ID = "co_id" Then E.Value = "2317"
  11.             If E.Value = " 查詢 " Then E.Click: Exit For
  12.         Next
  13.          T = Time
  14.         Do While .Busy Or .readyState <> 4 Or Time < (T + #12:00:02 AM#): DoEvents: Loop
  15.         Set E = .Document.all.tags("TABLE")(15)
  16.         For R = 0 To E.Rows.Length - 1
  17.             For C = 0 To E.Rows(R).Cells.Length - 1
  18.                 ActiveSheet.Cells(R + 1, C + 1) = E.Rows(R).Cells(C).INNERTEXT
  19.             Next
  20.         Next
  21.         .Quit
  22.     End With
  23. End Sub
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

ie.Document.GetElementByID("co_id").Value = 2317
處理完畢

反而找到該元件用e.value的方式無法輸入
PKKO

TOP

        靜思自在 : 犯錯出懺悔心,才能清淨無煩惱。
返回列表 上一主題