gpt4 book ai didi

javascript - IE 自动化单击按钮 VBA

转载 作者:行者123 更新时间:2023-12-03 11:18:35 26 4
gpt4 key购买 nike

我无法从 HTML 代码访问提交按钮,我尝试了一些代码,但这些代码不起作用。希望大家能从下面的信息中找到解决方案。

我的代码:

Sub GetIE()

Dim shellWins As ShellWindows
Dim IE As InternetExplorer

Set shellWins = New ShellWindows
Set IE = shellWins.Item(0)

IE.document.all("linerepricedamount").Value = "Value"
IE.document.all("linestatus").Value = "value"

'In Next step i want to click a submit button
'I Tried everything but those codes are not working

Set IE = Nothing
Set shellWins = Nothing

End Sub

HTML 代码:

<TD> <Input id="button" Type="Button" Value= "SaveLine" Name= "Button"
onclick="JavaScript:return save_line_onclick("saveline.d")> </TD>`

最佳答案

您需要触发 onclick 事件

Dim btnObject as Object

Set btnObject = IE.document.getElementbyID("button")
btnObject.FireEvent("onclick")

希望这能解决您的问题

关于javascript - IE 自动化单击按钮 VBA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27222444/

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