VBA run-time error '91' while automating IE7

tomsoyer

New Member
Joined
Mar 6, 2009
Messages
5
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
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
i don't see any reason for your error, it tested your code, worked ok with my internet explorer,though i think it is ver 6
 
Upvote 0
The code works for IE6, but not IE7. I am testing vba automation on IE7. I don't know if this is a bug in IE7, or an undocumented change. Very strange.
 
Upvote 0

Forum statistics

Threads
1,215,515
Messages
6,125,279
Members
449,220
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top