1
我正在尝试点击我使用VBA登录的网页上的按钮。我已经登录,现在我想继续这个过程并点击另一个按钮。以下是我迄今为止如何在登录后使用VBA点击网页中的按钮?
Sub MyGmail()
Dim HTMLDoc As HTMLDocument
Dim MyBrowser As InternetExplorer
Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
On Error GoTo Err_Clear
MyURL = "https://www.programworkshop.com/6.0.0.0/login/login.aspx?skin=default&lang=enu"
Set MyBrowser = New InternetExplorer
MyBrowser.Silent = True
MyBrowser.Navigate MyURL
MyBrowser.Visible = True
Do
Loop Until MyBrowser.ReadyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.Document
HTMLDoc.all.Login.value = "[email protected]"
HTMLDoc.all.pass.value = "Password"
HTMLDoc.all.btnlogin.Click
这下一行是我进入了死胡同
HTMLDoc.all.sd5.Click
下面是从网站的代码
<a id="sd5" class="nodeSel" href="javascript:treeAction(strURL5)" onmouseover="window.status='Examinees';return true;" onmouseout="window.status='';return true;" onclick="javascript: d.s(5);">Examinees</a>
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub
那么对于初学者'Document'没有被声明,所以你可能会在那里得到一个错误。 –
对不起,我忘了解决这个问题,试图与它一起玩。我现在修复了我的原始代码与同样的问题。 – Jexon
你是什么意思的“打到死胡同”?你需要做的第一件事就是摆脱'On Error GoTo Err_Clear',因为那样会阻止运行时错误,它会告诉你问题实际是什么(或至少提供了提示)。 –