【发布时间】:2017-09-11 21:11:15
【问题描述】:
以下宏在 IE9 中有效,但在使用 IE11 时,它在 Do While 语句处停止。此外,Set HTMLDoc = ie.document 也因同样的原因不起作用。
请注意,该网站将无法运行,因为它仅限于某些用户。
Option Explicit
Sub GetHTMLDocument()
Dim ie As New SHDocVw.InternetExplorer
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLInput As MSHTML.IHTMLElement
Dim htmlbuttons As MSHTML.IHTMLElementCollection
Dim htmlbutton As MSHTML.IHTMLElement
ie.Visible = True
ie.navigate "siiprodsrs01.db.sma"
Do While ie.readyState <> READYSTATE_COMPLETE
Loop
Set HTMLDoc = ie.document
Set HTMLInput = HTMLDoc.getElementById("what")
HTMLInput.Value = "12345"
Set htmlbuttons = HTMLDoc.getElementsByTagName("button")
For Each htmlbutton In htmlbuttons
Debug.Print htmlbutton.className, htmlbutton.tagName, htmlbutton.ID, htmlbutton.innerText
Next htmlbutton
htmlbuttons(0).Click
End Sub
【问题讨论】:
标签: vba internet-explorer