【发布时间】:2017-12-01 18:31:32
【问题描述】:
我有一个网页,我想自动登录并使用 vba 点击提交按钮,代码如下
'start a new subroutine called SearchBot
Sub SearchBot()
'dimension (declare or set aside memory for) our variables
Dim objIE As InternetExplorer 'special object variable representing the IE browser
Dim aEle As HTMLLinkElement 'special object variable for an <a> (link) element
Dim y As Integer 'integer variable we'll use as a counter
Dim result As String 'string variable that will hold our result link
'initiating a new instance of Internet Explorer and asigning it to objIE
Set objIE = New InternetExplorer
'make IE browser visible (False would allow IE to run in the background)
objIE.Visible = True
'navigate IE to this web page (a pretty neat search engine really)
objIE.navigate "mywebpage"
'wait here a few seconds while the browser is busy
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
'in the search box put cell "A2" value, the word "in" and cell "C1" value
objIE.document.getElementById("loginID").Value = ("userid")
objIE.document.getElementById("password").Value = ("password")
在这段代码之后,我想使用 vba 点击提交按钮
HTML 检查元素代码如下
<INPUT class=btn2 type=submit value=Submit name=submit1>
【问题讨论】: