Sub LoginToURL(userID As String)Dim ie As Object, iebody As String, strURL As String, strUsername As String, strPassword As StringSet 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 = Trueie.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
WendApplication.Wait (Now + TimeValue("0:00:05"))iebody = ie.Document.body.innerhtmlIf InStr(iebody, "The information you entered is invalid.") <> 0 Then
    MsgBox "Login failed!", vbCritical + vbOKOnly
Else
    MsgBox "Login successful!", vbInformation + vbOKOnly
End Ifie.ExecWB 6, 6ie.Quit
Set ie = NothingEnd Sub其中这段代码循环调用,老在ie.Document.All("ctl00_ContentPlaceHolder1_UserId").Value = strUsername这一行报“对象变量或with块变量未设置”的错误。大家帮我看看怎么改阿。多谢!