locked
Navigate and Set multiple HTMLDocument objects with Loops RRS feed

  • Question

  • Hi everyone,

    I'm writing a vba procedure (excel 2003) to browse multiple webpages and get their contents by assigning .document to respective elements in an object array.

    the relevant code section is:

    Sub gettest()
        Dim iURL(3) As String
        Dim docHTML(3) As HTMLDocument
        Dim oIE As InternetExplorer
    'generate url
        iURL(0) = "..."
        iURL(1) = "..."
        iURL(2) = "..."
    'open IE Set oIE = CreateObject("InternetExplorer.Application") With oIE .Visible = True For i = 0 To 2 .navigate iURL(i) Do Until .readyState = 4 DoEvents Loop Set docHTML(i) = .document ' Next End With ... End Sub

    But it turns out that all elements in said object array (docHTML) are assigned to the last webpage browsed (in this case, iURL(2)).

    Could anyone tell me how to solve this problem?

    Many thanks in advance...



    • Edited by pkusogno Saturday, May 19, 2012 10:15 AM
    Saturday, May 19, 2012 9:55 AM