返回列表 上一主題 發帖

[發問] 如何將從EXCEL內的資料貼入網站中(過程都由VBA自動執行)

本帖最後由 stillfish00 於 2013-10-18 16:22 編輯

回復 1# icestormer
  1. Sub Test()
  2.   Dim oIe, myData As DataObject, x
  3.   
  4.   Set myData = New DataObject  '需引用 MS Form Object Library
  5.   
  6.   With Sheets("問題")
  7.     .Range(.[A4], .[F4].End(xlDown)).Copy
  8.   End With
  9.   myData.GetFromClipboard
  10.   
  11.   Set oIe = CreateObject("internetExplorer.Application")
  12.   With oIe
  13.     '.Visible = False
  14.     .navigate "http://www.evepraisal.com"
  15.     Do While oIe.readystate <> 4: DoEvents: Loop
  16.    
  17.     .document.getElementById("raw_textarea").innerText = myData.GetText '填入
  18.     .document.getElementById("result_submit").Click 'submit
  19.    
  20.     Application.Wait Now + TimeValue("00:00:05")  '等待5秒完成
  21.    
  22.     Set x = .document.getElementById("result_container")
  23.     MsgBox x.All.tags("h4")(0).innerText
  24.     .Quit
  25.   End With
  26.   
  27. End Sub
複製代碼

TOP

本帖最後由 stillfish00 於 2013-10-21 16:50 編輯

回復 14# handsometrowa
http://www.w3school.com.cn/html/index.asp 可以先看一下 HTML 的元素、標籤、屬性
http://www.w3school.com.cn/htmldom/index.asp 再看看節點、訪問方法(這是歸類在javascript下的,但都大同小異)

然後比對看過的範例,再對照原始碼可能會比較有收穫,其實就是在樹中根據特定屬性找節點。

TOP

回復 15# icestormer
  1.     Set x = .document.getElementById("results").tFoot.all.tags("span")
  2.     [L22].Value = x(0).innerText & " : " & x(3).innerText
  3.     [L23].Value = x(1).innerText & " : " & x(4).innerText
  4.     [L24].Value = x(2).innerText & " : " & x(5).innerText
複製代碼

TOP

        靜思自在 : 得理要饒人,理直要氣和。
返回列表 上一主題