比如百度个人中心:https://passport.baidu.com/?login
那个用户名和密码都有id的,我直接:
-------------------
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate "https://passport.baidu.com/?login"
ie.Document.getElementById("username_normal").Value =1111111111111111111111
...
----------------------
就可以了.但是那个"登录"按钮我看了下,既没有id 也没有 name.查了下它的元素是<input type="submit" value=" 登录 ">
我试了下ie.Document.getElementsByTagName("submit").Click 也不行.像这种既没有id也没有name,要怎么自动点击呢?用.getelementBy  有没有什么普遍适用的准确点击法呢?(不用webbrowser.Document)多谢高手!

解决方案 »

  1.   

    dim submitBtn
    For Each submitBtn In ie.Document.All
            If LCase(submitBtn.tagname) = "input" Then
                If LCase(submitBtn.Type) = "submit" Then
                If submitBtn.Value = "登录" Then
                    submitBtn.Click  '点击
                 End If
                End If
            End If
        Next
    通用 可以搜索任何按扭或图片
      

  2.   

    感谢!!
    另外请教下,我试了下 ie.Document.Forms(0).submit ,以为这样应该可以直接提交表单,怎么也不行?
    非常谢谢!!