Hello Yosi,
We can grab a handle on the Internet Explorer to test whether it's open or not:<pre>
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Sub test()
Dim h As Long, IntEx As Object
h = FindWindow("ieframe", vbNullString)
If h > 0 Then
Set IntEx = _
GetObject(, "InternetExplorer.application")
IntEx.Visible = True
IntEx.Navigate "http://www.mrexcel.com"
Else: Set IntEx = CreateObject("WScript.Shell")
IntEx.Run "IExplore.exe http://www.MrExcel.com"
End If
End Sub</pre>
Edit: Depends what you by web site is open. If you meant that you I.E. is open, but if it's not on the MrExcel url, then open a new window, try:<pre>
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Option Compare Text
Sub test()
Dim h As Long, IntEx As Object
h = FindWindow("ieframe", vbNullString)
If h > 0 Then
Set IntEx = GetObject(, "InternetExplorer.application")
If InStr(IntEx.Document.url, "mrexcel.com") Then
IntEx.Visible = True
IntEx.navigate "http://www.mrexcel.com"
Exit Sub
Else: GoTo 1
End If
Else:
1: Set IntEx = CreateObject("WScript.Shell")
IntEx.Run "IExplore.exe http://www.mrexcel.com"
End If
End Sub</pre>
But this doesn't loop through windows, it'll grab the first instance.
Hope this helps.
_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue"> Oliver</font></font></font>
This message was edited by NateO on 2002-12-16 03:15