我不确定我是否正确引用了按钮。我不断得到:
Run-time error '438': Object doesn't support this property or method.
这就是我的代码目前的样子:
Sub russInd()
Dim oButton As Object, HTMLdoc As Object
Dim sht1 As Worksheet, myURL As String
Set ie = CreateObject("InternetExplorer.Application")
Set sht1 = Worksheets("Day 1")
myURL = sht1.Cells(32, 2).Value
ie.navigate myURL
ie.Visible = True
Do Until ie.ReadyState = 4
DoEvents
Loop
'Locate The correct forms and buttons
Set HTMLdoc = ie.document
Set oButton = HTMLdoc.querySelectorAll("a[href='javascript:submitForm(document.forms[0].action);']")
'Check All Checkboxes
HTMLdoc.getElementByID("chkAll").Click
oButton.Click
End Sub
我正在使用的网页是:
https://indexcalculator.ftserussell.com/
网页代码如下:
我需要点击下一步按钮,我试过使用
.getElementByID("CtlNavigation_lblControl")
要单击按钮,但只是跳过了命令,我猜它什么也没单击。谢谢!
querySelectorAll
返回 nodelist .您可能需要 querySelector
尝试
HTMLdoc.getElementById("CtlNavigation_lblControl").querySelector("a").Click
或
HTMLdoc.querySelector("CtlNavigation_lblControl a").Click
我是一名优秀的程序员,十分优秀!