打开后与IE标签交互

时间:2015-06-17 19:37:58

标签: excel vba internet-explorer excel-vba

我在这里尝试做的是在单独的IE标签中同时自动打开多个帮助台票证。我在Excel中创建了一个票号列表,然后遍历票号,打开每个票号。

当我在一个单独的IE实例中打开每个代码时,我的代码似乎工作正常,但由于我已经尝试在一个IE实例的单独选项卡中打开它们,我在第二个循环上出现错误。以下是我到目前为止的情况:

 
Set Tickets = Sheet5.Range("a1", Range("a1").End(xlDown))

Set ie = New InternetExplorerMedium
ie.Visible = 1
apiShowWindow ie.hwnd, SW_MAXIMIZE

For Each Ticket In Tickets

If Ticket <> "" And Not Ticket Like "IM*" And Not Ticket Like "ARS*" And Not      Ticket Like "C*" Then

    'Load Mantis Page
    If Tabbed = False Then
        ie.Navigate "http://URL"
    Else:
        ie.Navigate "http://URL", CLng(2048)
    End If

    Do
    DoEvents
    Loop Until ie.ReadyState = 4

    'LoginCheck
    Set LoginExists = ie.document.getElementById("username")
    If LoginExists Is Nothing Then
        GoTo SearchForTicket
    Else: GoTo Login
    End If

Login:
    Call ie.document.getElementById("username").SetAttribute("value", "xx")
    Call ie.document.getElementById("password").SetAttribute("value", "xx")
    ie.document.getElementById("login_form").Submit

    Do
    DoEvents
    Loop Until ie.ReadyState = 3
    GoTo SearchForTicket

    'Search for Mantis ticket
SearchForTicket:

    Application.Wait (Now + TimeValue("0:00:03"))

    ie.document.All("bug_id").Value = Ticket

    Set AllButtons = ie.document.getElementsByTagName("input")
        For Each Button In AllButtons
            If Button.Value = "Jump" Then
                Button.Click
                Exit For
            End If

        Next
End If
Tabbed = True
Next

它第一次工作,并打开IE浏览器,导航到页面并搜索故障单。第二次,它打开新选项卡并导航到页面,但当它尝试搜索第二张票时,我收到错误说:

Object doesn't support this property or method"

在线:

ie.document.All("bug_id").Value = Ticket

到目前为止,我一直在寻找一个没有运气的答案。任何帮助将不胜感激。

0 个答案:

没有答案