IE Automatin单击buttonVBA

我不能从我的HTML代码访问提交button,我尝试了一些代码,但这些东西不工作。 希望你们会从下面的信息中find解决办法。

我的代码:

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") 

希望这可以解决你的问题