VBA自动登录失败错误91

时间:2017-08-31 06:07:28

标签: html vba dom

基本上,我想自动登录一个网站,我可以找到id =“username”所以我可以使用IE.Document.getElementById(“username”)。value =“xxxxxxx”但是,它不起作用Dom没有任何价值输入。相反,当我尝试通过创建新属性 - 值=“xxxxxxx”来编辑HTML DOM时,它会显示网站上的用户名输入。我想知道我是否可以将其转移到vba并完成自动登录。非常感谢!关于这种情况显示的错误91

Sub Nomuralogin()

Dim IE As InternetExplorer
Dim Stockcode As String
Dim Stocktext As String, Textchange As String
Dim HTMLDoc As MSHTML.HTMLDocument
Dim IEField As HTMLInputElement
Dim i As Integer, nAsset As Integer

Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "https://www.nomuranow.com/portal/site/nnextranet/en/#curtain- login"
IE.Visible = True

Do While IE.Busy Or IE.ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop

Set HTMLDoc = IE.Document
Set IEField = HTMLDoc.getElementById("username")

IEField.Value = "abc@gmail.com"
'HTMLDoc.all.item("username").value = "abc@gmail.com" 
Application.Wait Now + TimeValue("00:00:03")
Application.DisplayAlerts = False

IE.Quit

Set IE = Nothing
End Sub

图1显示没有值输入: Pic 1

图2显示我已创建属性并添加了值输入: Pic 2

0 个答案:

没有答案