gpt4 book ai didi

javascript - 如何让 VBA 提交 javascript 表单?

转载 作者:太空宇宙 更新时间:2023-11-04 15:45:38 25 4
gpt4 key购买 nike

我不确定我是否正确引用了按钮。我不断得到:

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/

网页代码如下:

Web Page Code

我需要点击下一步按钮,我试过使用

.getElementByID("CtlNavigation_lblControl")

要单击按钮,但只是跳过了命令,我猜它什么也没单击。谢谢!

最佳答案

querySelectorAll 返回 nodelist .您可能需要 querySelector

尝试

HTMLdoc.getElementById("CtlNavigation_lblControl").querySelector("a").Click

HTMLdoc.querySelector("CtlNavigation_lblControl a").Click

关于javascript - 如何让 VBA 提交 javascript 表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56583758/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com