Hi,
While testing IE7 automation via VBA, I encountered this strange problem. I tried to navigate and parse HTML more than once in IE7 using a for loop (see code below). The code works only for the first loop; after that VBA gives this error message: "run-time error '91' "object variable or with block variable not set"". Does anyone know why it is not possible to execute the same block of VBA code (in my example below) more than once when working with IE7? Thanks.
Sub testIE7()
Dim objIE As InternetExplorer
Dim i, counter As Long
Set objIE = New InternetExplorer
For i = 1 To 2
counter = counter + 1
objIE.Visible = 0
objIE.Navigate2 "http://www.google.com/"
While objIE.Busy: Wend
While objIE.readyState <> 4: Wend
Debug.Print (objIE.document.getElementById("gbar").innerHTML & vbCrLf & "counter: " & counter)
Next i
End Sub
While testing IE7 automation via VBA, I encountered this strange problem. I tried to navigate and parse HTML more than once in IE7 using a for loop (see code below). The code works only for the first loop; after that VBA gives this error message: "run-time error '91' "object variable or with block variable not set"". Does anyone know why it is not possible to execute the same block of VBA code (in my example below) more than once when working with IE7? Thanks.
Sub testIE7()
Dim objIE As InternetExplorer
Dim i, counter As Long
Set objIE = New InternetExplorer
For i = 1 To 2
counter = counter + 1
objIE.Visible = 0
objIE.Navigate2 "http://www.google.com/"
While objIE.Busy: Wend
While objIE.readyState <> 4: Wend
Debug.Print (objIE.document.getElementById("gbar").innerHTML & vbCrLf & "counter: " & counter)
Next i
End Sub