te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - Fill user name and password in a webpage using VBA - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Fill user name and password in a webpage using VBA - Stack Overflow

programmeradmin4浏览0评论

This is my first try to navigate a IE browser through VBA. I am trying to: - go to this webpage .html - fill in the username - fill the password - click the "login" button for now I'm getting the error "Method 'Document' of object 'IWebBrowser2' failed"

I tried to inspect the elements in the html code of the webpage and found their ids but I suppose I'm making some mistake in invoking the methods or approaching the object.

my code is:

Option Explicit
Sub dataFromLeumi()
    Dim myPassword As String
    myPassword = "somepassword"
    Dim myUserName As String
    myUserName = "someusername"



    Dim loginPath As String
    loginPath = ".html"
    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.application")
    IE.Visible = True
    IE.navigate loginPath

    Dim userName As Object
    Set userName = IE.document.getattribute("uid")
    userName.Item(0).Value = myUserName

    Dim password As Object
    password = IE.document.getelementbyid("password")
    password.Item(0).Value = myPassword


    IE.document.getelementbyid("enter").Click
End Sub

What should I change in my code? What do I miss out?

Thanks!

This is my first try to navigate a IE browser through VBA. I am trying to: - go to this webpage https://hb2.bankleumi.co.il/e/Login.html - fill in the username - fill the password - click the "login" button for now I'm getting the error "Method 'Document' of object 'IWebBrowser2' failed"

I tried to inspect the elements in the html code of the webpage and found their ids but I suppose I'm making some mistake in invoking the methods or approaching the object.

my code is:

Option Explicit
Sub dataFromLeumi()
    Dim myPassword As String
    myPassword = "somepassword"
    Dim myUserName As String
    myUserName = "someusername"



    Dim loginPath As String
    loginPath = "https://hb2.bankleumi.co.il/e/Login.html"
    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.application")
    IE.Visible = True
    IE.navigate loginPath

    Dim userName As Object
    Set userName = IE.document.getattribute("uid")
    userName.Item(0).Value = myUserName

    Dim password As Object
    password = IE.document.getelementbyid("password")
    password.Item(0).Value = myPassword


    IE.document.getelementbyid("enter").Click
End Sub

What should I change in my code? What do I miss out?

Thanks!

Share Improve this question asked Jun 4, 2014 at 13:02 Max SegalMax Segal 2,0452 gold badges27 silver badges56 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 10

Try this

Sub test()
' open IE, navigate to the desired page and loop until fully loaded
    Set ie = CreateObject("InternetExplorer.Application")
    my_url = "https://hb2.bankleumi.co.il/e/Login.html"

    With ie
        .Visible = True
        .Navigate my_url
        .Top = 50
        .Left = 530
        .Height = 400
        .Width = 400

    Do Until Not ie.Busy And ie.readyState = 4
        DoEvents
    Loop

    End With

' Input the userid and password
    ie.Document.getElementById("uid").Value = "testID"
    ie.Document.getElementById("password").Value = "testPW"

' Click the "Search" button
    ie.Document.getElementById("enter").Click

    Do Until Not ie.Busy And ie.readyState = 4
        DoEvents
    Loop
End Sub
发布评论

评论列表(0)

  1. 暂无评论