使用VBA进行Web登录 [英] web login using VBA

查看:420
本文介绍了使用VBA进行Web登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用VBA访问我的web文件a / c。
第一步是尝试获取用户名和密码输入框的标签。



我使用inspect元素来确定标签,我认为他们是
username和password。但是,这不工作。很遗憾,我没有CSS的经验。



这是我的代码。

  Sub MyLogin()

设置ie = CreateObject(InternetExplorer.Application)
使用ie
.Visible = True
。导航http: //www.o2online.ie/o2/login/
Do Until .ReadyState = 4
DoEvents
Loop
.document.all.Item(username)。 =MyUsername
.document.all.Item(password)。Value =MyPassword
.document.forms(1).submit
结束于

End Sub

任何帮助。



Regards,Rueful

解决方案

由于登录表单位于iframe中,因此可能不允许直接访问控制。 >

尝试以下代码

  Sub MyLogin()
$ b b Set ie = CreateObject(InternetExplorer.Application)
使用ie
.Visible = True
。导航https://www.o2online.ie/idm/login/lightBoxLogin.jsp ?authn_try_count = 0& contextType = external& username

Do Until .ReadyState = 4
DoEvents
Loop

.document.all.Item username)。Value =MyUsername
.document.all.Item(password)。Value =MyPassword
.document.forms(0).submit
。 http://www.o2online.ie/o2/login/

结束
结束子


I'm trying to access my webtext a/c using VBA. The first step is trying to get the tag for the username and password input boxes.

I've used inspect elements to determine the tags and I think they are "username" and "password". However, this does not work. Unfortunately, I've no experience of CSS.

Here is my code.

Sub MyLogin()

    Set ie = CreateObject("InternetExplorer.Application")
    With ie
        .Visible = True
        .Navigate "http://www.o2online.ie/o2/login/"
        Do Until .ReadyState = 4
            DoEvents
        Loop
        .document.all.Item("username").Value = "MyUsername"
        .document.all.Item("password").Value = "MyPassword"
        .document.forms(1).submit
    End With

End Sub

Any help appreciated.

Regards, Rueful

解决方案

As the login form is inside iframe it may not allow to access the control directly.

Try below code

Sub MyLogin()

    Set ie = CreateObject("InternetExplorer.Application")
    With ie
        .Visible = True
        .Navigate "https://www.o2online.ie/idm/login/lightBoxLogin.jsp?authn_try_count=0&contextType=external&username"

        Do Until .ReadyState = 4
            DoEvents
        Loop

        .document.all.Item("username").Value = "MyUsername"
        .document.all.Item("password").Value = "MyPassword"
        .document.forms(0).submit
        .Navigate "http://www.o2online.ie/o2/login/"
    End With

End Sub

这篇关于使用VBA进行Web登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆