microsoft网站使用VBA实现IE登录自动化失败

microsoft网站使用VBA实现IE登录自动化失败,vba,internet-explorer,browser-automation,Vba,Internet Explorer,Browser Automation,我有下面的代码,它可以正常工作,直到它填写我的用户名和Microsoft登录网站似乎产生奇怪的错误,我不知道如何前进。请参阅代码和图片以更好地了解此问题 试试这个。它应该能让你达到目的: Sub Log_In() Dim IE As New InternetExplorer, html As HTMLDocument With IE .Visible = True .navigate "https://login.microsoftonline

我有下面的代码,它可以正常工作,直到它填写我的用户名和Microsoft登录网站似乎产生奇怪的错误,我不知道如何前进。请参阅代码和图片以更好地了解此问题


试试这个。它应该能让你达到目的:

Sub Log_In()
    Dim IE As New InternetExplorer, html As HTMLDocument

    With IE
        .Visible = True
        .navigate "https://login.microsoftonline.com/"
        While .readyState < 4:  DoEvents:  Wend
        Set html = .document
    End With

    Application.Wait Now + TimeValue("00:00:05")

    html.getElementsByName("loginfmt")(0).innerText = "your_email"
    Application.Wait Now + TimeValue("00:00:03")

    html.getElementById("idSIButton9").Click
    Application.Wait Now + TimeValue("00:00:05")

    html.getElementsByName("passwd")(0).innerText = "your_password"
    Application.Wait Now + TimeValue("00:00:03")

    html.getElementById("idSIButton9").Click

    IE.Quit
End Sub
Sub Log_In()
Dim IE作为新的InternetExplorer,html作为HTMLDocument
与IE
.Visible=True
.导航“https://login.microsoftonline.com/"
While.readyState<4:DoEvents:Wend
设置html=.document
以
应用程序。立即等待+时间值(“00:00:05”)
html.getElementsByName(“loginfmt”)(0.innerText=“您的电子邮件”
应用程序。立即等待+时间值(“00:00:03”)
html.getElementById(“idSIButton9”)。单击
应用程序。立即等待+时间值(“00:00:05”)
html.getElementsByName(“passwd”)(0.innerText=“您的密码”
应用程序。立即等待+时间值(“00:00:03”)
html.getElementById(“idSIButton9”)。单击
即退出
端接头

谢谢。这很有效。我已成功使用sendkeys,但您的解决方案更好。
Sub Log_In()
    Dim IE As New InternetExplorer, html As HTMLDocument

    With IE
        .Visible = True
        .navigate "https://login.microsoftonline.com/"
        While .readyState < 4:  DoEvents:  Wend
        Set html = .document
    End With

    Application.Wait Now + TimeValue("00:00:05")

    html.getElementsByName("loginfmt")(0).innerText = "your_email"
    Application.Wait Now + TimeValue("00:00:03")

    html.getElementById("idSIButton9").Click
    Application.Wait Now + TimeValue("00:00:05")

    html.getElementsByName("passwd")(0).innerText = "your_password"
    Application.Wait Now + TimeValue("00:00:03")

    html.getElementById("idSIButton9").Click

    IE.Quit
End Sub