gpt4 book ai didi

VBA IE 更改下拉值

转载 作者:行者123 更新时间:2023-12-04 20:33:53 26 4
gpt4 key购买 nike

尝试以下 URL 的代码 Scripture look up .请如何从 WEB 更改下拉值至RV1909 ?

Dim Doc As HTMLDocument
Set Doc = IEApp.document

TestV2 = ""
TestV3 = ""

TestV2 = Doc.getElementsByClassName("app-list text-list")(0).innerText
Debug.Print "4b of 5: " & TestV2

IEApp.Doc.getElementsByClassName("app-list text-list").selectedIndex = 1
IEApp.Doc.getElementsByClassName("app-list text-list").FireEvent ("onchange")

TestV3 = Doc.getElementsByClassName("app-list text-list")(0).innerText
Debug.Print "4c of 5: " & TestV3

尝试了其他帖子的许多方法,以下方法不起作用:

IEApp.Doc.getElementsByClassName("app-list text-list")(0).innerHTML = "RV1909"

这是 Chrome Inspector 的屏幕截图:

Screenshot of Chrome Inspector

最佳答案

在这种情况下,仅更改 div.app-list.text-list 是不够的元素 innerText ,如您所见,该元素很简单 div ,但甚至没有 ul .它应该由在 click 上调用的脚本更改。事件。所以,首先你需要点击div显示整个列表,然后单击 RV1909 项目。下面的例子展示了如何做到这一点:

Sub Test()

Dim oIE As Object
Dim oDiv As Object

Set oIE = CreateObject("InternetExplorer.Application")
With oIE
.Visible = True
.Navigate "http://ebible.org/study/"
Do While .readyState <> 4 Or .Busy
DoEvents
Loop
With .Document
Do While .readyState <> "complete"
DoEvents
Loop
Set oDiv = .getElementsByClassName("app-list text-list")(0)
oDiv.Click
Do While .readyState <> "complete"
DoEvents
Loop
For Each oNode In .getElementsByClassName("text-chooser-main")(0).getElementsByClassName("text-chooser-abbr")
If oNode.innerText = "RV1909" Then
oNode.Click
Do While oDiv.innerText <> "RV1909"
DoEvents
Loop
Exit For
End If
Next
End With
End With

End Sub

关于VBA IE 更改下拉值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45391311/

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