无法访问登录按钮..VBA代码

时间:2016-06-08 03:03:39

标签: excel vba excel-vba

Sub login()
  Dim IE As Object
  Dim HTMLDoc As Object, HTMLDoc2 As Object
  Dim objCollection As Object

  Const navOpenInNewTab = &H800
  Set IE = CreateObject("InternetExplorer.Application")
  IE.Visible = True
  IE.Navigate "https:///CWRWeb/displayMemberLogin.do"

  Do While IE.Busy Or IE.ReadyState <> 4: Loop

  Set HTMLDoc = IE.Document

  With HTMLDoc
  HTMLDoc.getElementByID("userID").Value = "yyyy"    'Entering credential
  HTMLDoc.getElementByID("passwd").Value = "xxxxx"
  End With


  Set objCollection = IE.Document.getElementByID("login-s")
  objCollection.Click

End Sub

我无法自动登录点击。登录按钮没有输入ID。我不知道如何使用句柄 .getElementBy ....

1 个答案:

答案 0 :(得分:1)

表单有一个名称 - 您可以在填写用户名和密码后直接提交

HTMLDoc.Forms("loginFormBean").submit