Sub LoginToURL(userID As String) Dim ie As Object, iebody As String, strURL As String, strUsername As String, strPassword As String Set ie = CreateObject("InternetExplorer.Application") strURL = "http://192.168.0.101/kanyos2/Student/StudentTranscript.aspx?studentID=" & userID
strUsername = "admin"
strPassword = "000000" ie.Navigate strURL
'Wait until page is loaded.
While ie.ReadyState < 4 ' READYSTATE_COMPLETE = 4
DoEvents
Wend ie.Document.Visible = True ie.Document.All("ctl00_ContentPlaceHolder1_UserId").Value = strUsername
ie.Document.All("ctl00_ContentPlaceHolder1_Password").Value = strPassword
ie.Document.All("ctl00_ContentPlaceHolder1_login").Click
'Wait until page is loaded.
While ie.ReadyState < 4 ' READYSTATE_COMPLETE = 4
DoEvents
Wend Application.Wait (Now + TimeValue("0:00:05")) iebody = ie.Document.body.innerhtml If InStr(iebody, "The information you entered is invalid.") <> 0 Then
MsgBox "Login failed!", vbCritical + vbOKOnly
Else
MsgBox "Login successful!", vbInformation + vbOKOnly
End If ie.ExecWB 6, 6 ie.Quit
Set ie = Nothing End Sub 其中这段代码循环调用,老在ie.Document.All("ctl00_ContentPlaceHolder1_UserId").Value = strUsername这一行报“对象变量或with块变量未设置”的错误。大家帮我看看怎么改阿。多谢!
strUsername = "admin"
strPassword = "000000" ie.Navigate strURL
'Wait until page is loaded.
While ie.ReadyState < 4 ' READYSTATE_COMPLETE = 4
DoEvents
Wend ie.Document.Visible = True ie.Document.All("ctl00_ContentPlaceHolder1_UserId").Value = strUsername
ie.Document.All("ctl00_ContentPlaceHolder1_Password").Value = strPassword
ie.Document.All("ctl00_ContentPlaceHolder1_login").Click
'Wait until page is loaded.
While ie.ReadyState < 4 ' READYSTATE_COMPLETE = 4
DoEvents
Wend Application.Wait (Now + TimeValue("0:00:05")) iebody = ie.Document.body.innerhtml If InStr(iebody, "The information you entered is invalid.") <> 0 Then
MsgBox "Login failed!", vbCritical + vbOKOnly
Else
MsgBox "Login successful!", vbInformation + vbOKOnly
End If ie.ExecWB 6, 6 ie.Quit
Set ie = Nothing End Sub 其中这段代码循环调用,老在ie.Document.All("ctl00_ContentPlaceHolder1_UserId").Value = strUsername这一行报“对象变量或with块变量未设置”的错误。大家帮我看看怎么改阿。多谢!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货