VBA自动URL登录Windows 10

时间:2018-07-16 14:36:26

标签: excel-vba

我需要在Windows安全窗口(已安装Win 10)中自动登录到需要用户名和密码的URL。 我有以下代码,但卡在了身份验证安全窗口中:

Sub GO_Click()

    Const Url$ = "url_removed"

    Dim UserName As String, Password As String, LoginData As Workbook
    UserName = "urn"
    Password = "Pa$$"

    Dim ie As Object
    Set ie = CreateObject("InternetExplorer.Application")

    With ie

        .navigate Url
        ieBusy ie
        .Visible = True

        Dim oLogin As Object, oPassword As Object
        Set oLogin = .document.getElementsByName("ecp_param_userId")(0)
        Set oPassword = .document.getElementsByName("ecp_param_password")(0)

        oLogin.Value = UserName
        oPassword.Value = Password
        .document.forms(0).submit

    End With
End Sub

Sub ieBusy(ie As Object)
    Do While ie.Busy Or ie.readyState < 4
        DoEvents
    Loop
End Sub

snapshot from test

0 个答案:

没有答案