VBA操作IE

删除回忆录丶 提交于 2020-02-26 23:17:17
1.参照项目
  Microsoft Internet Controls
  Microsoft HTML Object
 
2.sample
Sub GetIEItem()


Dim objIE As InternetExplorer

Set objIE = CreateObject("Internetexplorer.Application")

objIE.Visible = True

Dim url As String

url = "https://www.baidu.com/"

objIE.Navigate url, "JDK1.8"

Application.Wait Now() + TimeValue("00:00:03")

Dim htmlDoc As HTMLDocument

Set htmlDoc = objIE.Document

htmlDoc.getElementById("kw").value = "JDK1.8"

htmlDoc.getElementById("su").Click

Application.Wait Now() + TimeValue("00:00:03")


' Dim element As IHTMLElement
'
' For Each element In htmlDoc.getElementsByTagName("h1")
' Debug.Print element.innerText
' Next element
'
' Dim tr As HTMLTableRow
' For Each tr In htmlDoc.getElementsByTagName("tbody")(0).getElementsByTagName("tr")
'
' Next tr

End Sub
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!