“对象变量或with块变量未设置”的错误。大家帮我看看怎么改阿。多谢!

Charlie_YAN 2009-01-06 06:00:09
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块变量未设置”的错误。大家帮我看看怎么改阿。多谢!
...全文
76 回复 点赞 打赏 收藏 举报
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
VB基础类
加入

7543

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2009-01-06 06:00
社区公告
暂无公告