|
点击时出现“方法all作用于对象'DispHTMLFormElement'时失败”,源代码为
Dim x, y As Integer
Dim div1 As Object
Dim urlstr As String
urlstr = "http://*******/sycgs/Login.aspx"
Dim IEOBJ As Object
Set IEOBJ = CreateObject("InternetExplorer.Application")
IEOBJ.Visible = True
IEOBJ.navigate urlstr
Do Until IEOBJ.Readystate = 4
DoEvents
Loop
IEOBJ.document.forms(0).all("UserName").Value = "username"
IEOBJ.document.forms(0).all("Password").Value = "password"
IEOBJ.document.forms(0).all("Btok").Click
Dim id As String
urlstr = "http://*******/sycgs/Management/Adduser.aspx"
x = ThisWorkbook.Sheets(1).Cells(1, 1)
While x < ThisWorkbook.Sheets(1).Cells(1, 2)
Set IEOBJ = CreateObject("InternetExplorer.Application")
IEOBJ.Visible = True
IEOBJ.navigate urlstr
Do Until IEOBJ.Readystate = 4
DoEvents
Loop
With IEOBJ
.document.forms(0).all("username").Value = ThisWorkbook.Sheets(1).Cells(x, 6)
.document.forms(0).all("name").Value = ThisWorkbook.Sheets(1).Cells(x, 5)
.document.forms(0).all("password1").Value = ThisWorkbook.Sheets(1).Cells(x, 7)
.document.forms(0).all("phone").Value = ThisWorkbook.Sheets(1).Cells(x, 10)
.document.forms(0).all("address").Value = ThisWorkbook.Sheets(1).Cells(x, 8)
.document.forms(0).all("UserList_1").Checked = True
.document.forms(0).all("UserList_3").Checked = True
.document.forms(0).all("Button1").Click
End With
IEOBJ.document.forms(0).all("txdept").Click
id = ThisWorkbook.Sheets(1).Cells(x, 11)
IEOBJ.document.forms(0).all(id).Click
Do Until IEOBJ.Readystate = 4
DoEvents
Loop
x = x + 1
ThisWorkbook.Sheets(1).Cells(1, 1) = x
Wend
请高手指点! |
|