0

我正在尝试使用 Excel VBA 脚本在 Web 应用程序上创建多个用户。下面的代码适用于第一行用户创建,但在第二行的设置文档处停止。实际上,Web 应用程序页面重定向到不同的页面,我认为这导致了这里的问题。有人可以帮我在这里循环每一行的 URL1。

Sub Usercreation()
 Dim UC As Object
 Dim doc As HTMLDocument 

 Set UC = CreateObject("internetexplorer.application")
 lr = ThisWorkbook.Sheets("Data").Cells(Rows.Count, 1).End(xlUp).Row  

 UC.Visible = True
 UC.navigate "URL1"

 Do While UC.Busy
   Application.Wait DateAdd("s", 1, Now)
   DoEvents

 Loop

 For introw = 2 To lr  

 Set doc = UC.document

     doc.getElementById("FirstName").Value = ThisWorkbook.Sheets("Data").Range("A" & introw).Value
     doc.getElementById("LastName").Value = ThisWorkbook.Sheets("Data").Range("B" & introw).Value
     doc.getElementById("MobileNo").Value = ThisWorkbook.Sheets("Data").Range("C" & introw).Value
     doc.getElementById("Email").Value = ThisWorkbook.Sheets("Data").Range("D" & introw).Value
     doc.getElementById("Username").Value = ThisWorkbook.Sheets("Data").Range("E" & introw).Value
     doc.getElementById("Password").Value = ThisWorkbook.Sheets("Data").Range("F" & introw).Value
     doc.getElementById("ConfirmPassword").Value = ThisWorkbook.Sheets("Data").Range("G" & introw).Value
     doc.getElementById("Name").Value = ThisWorkbook.Sheets("Data").Range("H" & introw).Value
     doc.getElementsByClassName("btn btn-default")(0).Click

  Application.Wait DateAdd("s", 2, Now)

  UC.Quit
  Set UC = Nothing


 Next introw

End Sub

4

0 回答 0