【发布时间】:2018-01-24 13:10:35
【问题描述】:
我正在尝试处理单击页面上的按钮\行,然后在新页面加载时单击其他内容。我可以让我的 vba 单击第一个按钮/链接,但是当尝试单击下一个时,我收到错误
运行时错误 91:对象变量或未设置块变量
现在我必须说实话,我所拥有的代码是来自研究的,而且我并不完全理解它,我已经搜索了所有内容,试图纠正第二次点击,但似乎没有任何效果。
我目前的代码是
Public Sub SHAREREPORTING()
Dim IE As SHDocVw.InternetExplorer
Dim Button As Object
Dim Button2 As Object
Set IE = New InternetExplorerMedium
IE.Visible = True
IE.navigate "URL"
Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
Set Button = IE.Document.getElementById("b1_pki")
Button.Click
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys "mypassword" , True
SendKeys "{ENTER}", True
Do While IE.ReadyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop
Set Button2 = IE.Document.getElementById("seite-itm-2")
Application.Wait (Now + TimeValue("0:00:05"))
Button2.Click
End Sub
2 个按钮的代码(我称它们为按钮/链接,因为我不太确定它们是什么,我不懂 javascript)我现在尝试点击的是
按钮1/链接1
<A onclick=loginViaPKI(); onkeypress=loginViaPKI(); id=b1_pki title="Log on with PKI - Button - To activate, press spacebar." class=urBtnEmph hideFocus style="WHITE-SPACE: nowrap" href="javascript:void(0);" ct="Button">Log on with PKI</A>
按钮2/链接2
<TD onclick="return htmlbSL(this,7,'seite:sel_tab_2','','3','sel_tab_2')" id=seite-itm-2 class=urTbsLabelOff onkeydown="if (sapUrMapi_checkKey(event,'keydown',new Array('32'))){return htmlbSL(this,7,'seite:sel_tab_2','','3','sel_tab_2')};sapUrMapi_TabStrip_keySelect('seite',2,4,event);" noWrap><SPAN id=seite-itm-2-txt title="Bookmarks " class=urTbsTxtOff>Bookmarks </SPAN></TD>
【问题讨论】:
标签: vba excel internet-explorer