0

おはようございます!ページ上のいくつかのボタンをクリックするマクロを開発していますが、一部のボタンが機能しません。誰かが理由を知っていますか?

ワークシートを次の場所に投稿しました: http://www.sendspace.com/file/3if8c6

助けてくれてありがとう。

シルマー

4

1 に答える 1

0

スプレッドシートに、クリックできない 02 ボタンの写真を投稿しました。とにかく、ここにコードを投稿します。

ありがとう!

Sub test()
Dim ie
Dim obj
Dim obj2
Dim linkCollection2
Dim elemCollection
Dim t As Integer
Dim r As Integer, c As Integer

Set ie = CreateObject("internetexplorer.application")
ie.Navigate2 "http://www.infomoney.com.br/mercados/agendas"
 ie.Visible = True

Do While ie.Busy
Loop
Do Until ie.Document.ReadyState = "complete"
Loop

Dim LinkFound As Boolean
Dim linkCollection

Set linkCollection = ie.Document.getElementsByTagName("A")
For Each link In linkCollection
If link.InnerText = "Resultados" Then
LinkFound = True
link.Click
Exit For
End If

Next

If Not LinkFound Then
MsgBox "Link Not Found!"
Exit Sub
End If

Do While ie.Busy
Loop
Do Until ie.Document.ReadyState = "complete"
Loop

    For Each obj In ie.Document.All.Item("ctl00$cphContent$ctl02$ddlReferencePage").Options
        If obj.InnerText = "3T12" Then
            obj.Selected = True
          '  ie.Document.forms(0).submit
            Exit For
        End If
    Next obj

    Set linkCollection2 = ie.Document.getElementsByTagName("A")
For Each link In linkCollection2
If link.InnerText = "Resultados" Then
LinkFound = True
link.Click
Exit For
End If

Next
        Set elemCollection = ie.Document.getElementsByTagName("TABLE")
        For t = 0 To elemCollection.Length - 1
        For r = 0 To elemCollection(t).Rows.Length - 1
            For c = 0 To elemCollection(t).Rows(r).Cells.Length - 1
                ThisWorkbook.Worksheets(1).Cells(r + 1, c + 1) = elemCollection(t).Rows(r).Cells(c).InnerText
            Next c
        Next r
    Next t

    ' The error happens here
' TO FROM HERE DOES NOT WORK. WHY?

    For Each obj2 In ie.Document.All.Item("tblCInvestorData_length").Options
        If obj.InnerText = "100" Then
            obj2.Selected = True
          '  ie.Document.forms(0).submit
            Exit For
        End If
    Next obj2

End Sub
于 2013-01-20T02:06:24.700 に答える