Dim WithEvents IE As InternetExplorer
Dim IES() As InternetExplorer
Private Sub Form_Load()
ReDim IES(0)
Set IE = New InternetExplorer
Set IES(0) = IE
IES(0).Navigate "www.google.com"
IES(0).Visible = True
End Sub
Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
For x = 0 To UBound(IES)
If (pDisp Is IES(x).Application) Then
Debug.Print "IE #" & x
If UBound(IES) = 2 Then Exit Sub 'added this so it stops at 5 instances
Add_New_IE
End If
Next
If (URL = "http://www.google.co.uk/") Then
IES(x).Document.Forms(0).q.Value = x
End If
End Sub
Private Sub Add_New_IE()
ReDim Preserve IES(UBound(IES) + 1)
Set IE = New InternetExplorer
Set IES(UBound(IES)) = IE
IES(UBound(IES)).Navigate "www.google.com"
IES(UBound(IES)).Visible = True
End Sub