Tag: ie automation

使用VBA在IE中单击一个button

我正在使用Excel VBA来尝试点击网站上的button,这里是使用inspect元素的网站代码: <button class="_ah57t _84y62 _frcv2 _rmr7s">ClickHere</button> 以下是我在VBA中所做的: Sub testcode() Dim ie As InternetExplorer Dim html As HTMLDocument Set ie = New InternetExplorer ie.Visible = True ie.Navigate "somesite.com" Do While ie.READYSTATE <> READYSTATE_COMPLETE DoEvents Loop Dim e Set e = ie.Document.getElementsByClassName("_ah57t _84y62 _frcv2 _rmr7s") e.Click End Sub 使用debugging,我发现代码似乎在variablese中存储了一个名为“[object]”的东西,然后在e.click中出现运行时错误“438”。 我甚至尝试使用.Focus第一,但得到相同的错误。 有任何想法吗?