IE Automation单击按钮VBA

时间:2014-12-01 05:52:56

标签: javascript excel vba automation

我无法从我的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 CODE:

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

1 个答案:

答案 0 :(得分:1)

您需要触发onclick事件

Dim btnObject as Object

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

希望这能解决您的问题

相关问题