0
我想要做的是打开一个网站,然后按下按钮。我不能让它工作,所以我要求你们所有有经验的程序员!IE页面上的VBA点击按钮
按钮XML记录是:
z-menu-item-inner-r"><span class="z-menu-item-space"></span></td></tr></tbody></table></a></td><td id="z_e6_mm" align="left" z.type="Menuit2" class="z-menu-item " style="padding-left:4px;padding-right:4px;" z.zcls="z-menu-item" z.top="true"><a href="/NTS/NTSBatchJobs.zul" class="z-menu-item-cnt"><table id="z_e6_mm!a" cellspacing="0" cellpadding="0" border="0" class="z-menu-item-body " style="width: auto;"><tbody><tr><td class="z-menu-item-inner-l"><span class="z-menu-item-space"></span></td><td class="z-menu-item-inner-m"><div><button id="z_e6_mm!b" type="button" class="z-menu-item-btn">**HIT ME** </button></div></td><td class="
按钮我试图按被命名为: HIT ME
我使用的代码:
Sub IE_Auto()
Dim i As Long
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "mysite"
Set elems = IE.Document.getElementsByTagName("button")
For Each e In elems
If e.Name = "Hit Me" Then
e.Click
Exit For
End If
Next e
End Sub
谢谢您的快速响应。我得到运行时错误:自动化错误。接口是未知的,它停在设置btn = IE.Document.getElementById(“z_e6_mm!b”) – Golemic
需要IE8 +你有什么版本?您可能还需要为IE准备好/等待循环以允许页面完成加载。同样,从XML验证正确的元素ID。 –
我的IE版本是8.0.7601.17514。我也添加了一个等待循环,持续10秒:Application.Wait DateAdd(“s”,10,Now)。我如何验证这是正确的元素?我用按钮标题搜索! – Golemic