我正在使用 Excel VBA 尝试单击站点上的按钮,这是该站点使用检查元素的代码:
<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
使用调试,我发现代码似乎在变量 e 中存储了一个名为“[object]”的东西,然后在到达 e.click 时给出了运行时错误“438”。我什至尝试过先使用 .Focus,但得到了同样的错误。有任何想法吗?