运行时错误'91'仍然一无所获

时间:2019-07-09 20:01:40

标签: excel vba

我已经遍历了Interweb的各个层次,试图弄清我在做什么错。我尝试了几十种不同的方法,但似乎没有任何效果。我在相同的位置“ UsernameInputBox.Value = cuserId”处始终得到相同的运行时错误“ 91”代码。昨天,在该站点的帮助下,我能够对其进行一些清理,但是我仍然是菜鸟,而且进展不大。有人可以告诉我我在做什么错吗?请,谢谢。

   Sub Chase()

Const cURL = "https://www.chase.com/"
Const cuserId = "XXXXXXX"
Const cpassword = "XXXXXXX"

Dim IE As InternetExplorer
Dim doc As HTMLDocument
Dim LoginForm As HTMLFormElement
Dim UsernameInputBox As HTMLInputElement
Dim PasswordInputBox As HTMLInputElement
Dim SigninButton As HTMLInputButtonElement
Dim HTMLelement As IHTMLElement
Dim qt As QueryTable

Set IE = New InternetExplorer

IE.Visible = True
IE.navigate cURL

'Wait for initial page to load

Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop

Set doc = IE.document

'Get the only form on the page

Set LoginForm = doc.forms(0)

'Get the Username textbox and populate it
'input name="userId" id="userId-input-field" size="18" value="" class="jpui input logon-xs-toggle clientSideError" type="text"

Set UsernameInputBox = doc.getElementById("userId-input-field")
UsernameInputBox.Value = cuserId

'Get the Password textbox and populate it
'input name="password" id="password-input-field" size="18" class="jpui input logon-xs-toggle clientSideError" type="password"


Set PasswordInputBox = doc.getElementById("password-input-field")
PasswordInputBox.Value = cpassword

'Get the form input button and click it
'button class="jpui button focus fluid primary" name="Sign in" id="signin-button" value="Sign in" type="submit"

Set SigninButton = doc.getElementById("signin-button")
SigninButton.Click

'Wait for the new page to load

Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop

End Sub

0 个答案:

没有答案