使用VBA登录网站并清除以前的登录凭据
我目前正在使用此代码登录到一个网站,但我遇到了一个问题。由于用户名和密码已保存在浏览器上,因此再次添加uid/pass并在登录过程中产生错误。有没有办法添加一些代码来清除以前输入的uid/pass使用VBA登录网站并清除以前的登录凭据,vba,excel,Vba,Excel,我目前正在使用此代码登录到一个网站,但我遇到了一个问题。由于用户名和密码已保存在浏览器上,因此再次添加uid/pass并在登录过程中产生错误。有没有办法添加一些代码来清除以前输入的uid/pass Sub test() ' open IE, navigate to the desired page and loop until fully loaded Set ie = CreateObject("InternetExplorer.Application") my_url = "https:/
Sub test()
' open IE, navigate to the desired page and loop until fully loaded
Set ie = CreateObject("InternetExplorer.Application")
my_url = "https://hb2.bankleumi.co.il/e/Login.html"
With ie
.Visible = True
.Navigate my_url
.Top = 50
.Left = 530
.Height = 400
.Width = 400
Do Until Not ie.Busy And ie.readyState = 4
DoEvents
Loop
End With
' Input the userid and password
ie.Document.getElementById("uid").Value = "testID"
ie.Document.getElementById("password").Value = "testPW"
' Click the "Search" button
ie.Document.getElementById("enter").Click
Do Until Not ie.Busy And ie.readyState = 4
DoEvents
Loop
End Sub
您可以测试当前加载的用户名是否相同,如果相同,只需单击,否则,使用
.Value=”“
您可以测试当前加载的用户名是否相同,如果相同,只需单击,否则,使用
.Value=”“
首先检查该值是否已经是当前用户名,在这种情况下,只需继续并单击;否则,尝试用
.Value=”“
行?@ScottHoltzman Brilliant清除它。使用.value=”“清除它非常有效。非常感谢你!如果你将其作为一个答案发布,我将非常乐意接受它,这样线程就可以关闭。首先检查该值是否已经是当前用户名,在这种情况下,只需继续并单击;否则,尝试用.Value=”“
行?@ScottHoltzman Brilliant清除它。使用.value=”“清除它非常有效。非常感谢你!如果你把它作为一个答案,我会非常高兴地接受它,这样线程可以关闭。
If ie.Document.getElementById("uid").Value = "testID" Then
Else
ie.Document.getElementById("uid").Value = ""
ie.Document.getElementById("password").Value = ""
ie.Document.getElementById("uid").Value = "testID"
ie.Document.getElementById("password").Value = "testPW"
End If