运行时错误13'在getElementByID中输入Mismatch' [英] Run-time error 13 'Type Mismatch' in getElementByID

查看:127
本文介绍了运行时错误13'在getElementByID中输入Mismatch'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好VBA大师,我是初学者,这是我遇到的问题。

Hello VBA Gurus, I am a beginner and here is the problem I am encountering.

我正在尝试使用Excel中的VBA自动进行Web登录,我正在获得运行时错误13弹出。

I am trying to automate web login using VBA in Excel and I am getting runtime error 13 pop up.

我使用过在不同网站上找到的代码,现在是。任何帮助将不胜感激。

I have used codes found across different websites and here it is. Any help will be appreciated.

Sub test()
' open IE, navigate to the desired page and loop until fully loaded
    Dim IE As InternetExplorerMedium
    Set IE = New InternetExplorerMedium
    my_url = "http://appln.ABCPQR.com.au/index.epl"

    With IE
        .Visible = True
        .Navigate my_url
   
    Do Until Not IE.Busy And IE.readyState = 4
        DoEvents
    Loop

    End With
    
'no error till this point. Run Time error 13 appears because of following code
 
    Set UserName = IE.Document.getElementById("login_usr")
    UserName.Value = "ABCDE"

    Set Password = IE.Document.getElementById("login_password")
    Password.Value = "ABCDE"

    Set btnLogin = IE.Document.getElementById("Login")
    btnLogin.Click
  
End Sub

请查看第二条评论专栏。我已经能够将错误本地化为这段代码。

Please look at the second comment line. I have been able to localise the error to this block of code.

期待您的建议。

干杯!

推荐答案

我建​​议使用Selenium Basic。 请参阅
this

I would recommend using Selenium Basic.  Refer to this


这篇关于运行时错误13'在getElementByID中输入Mismatch'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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