see if there is an IE window already open...

Beastr0

New Member
Joined
Dec 28, 2004
Messages
22
I have no problem using the lables to find other applications that are open within windows but IE is different because it lables the window with the name of the site as well.. is there a way to just find an open IE window regardless of the lable and set focus on it? And of course change the IE Address once selected (or else I end up with Wayyyyyy to many Explorer windows open)
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Well I did come up with something that seems to work fairly well but if the window is minimized it does not set the focus on it.. other than that it does everything I want it to do... the code goes as follows

Sub UseExplorer()
Dim sw As Object, ie As Object
Set sw = CreateObject("Shell.Application").Windows
Dim FoundIE As Integer

FoundIE = 0
For Each ie In sw
If FoundIE = 1 Then
ie.navigate Site
Exit Sub
Else
'distinguish Internet Explorer from Windows Explorer
If InStr(UCase(ie.FullName), "\IEXPLORE.EXE") <> 0 Then
FoundIE = FoundIE + 1
If ie.hwnd = 3540814 Then
FoundIE = 0
Else
ShowWindow ie.hwnd, 2
ShowWindow ie.hwnd, 4
SetActiveWindow ie.hwnd
ie.navigate Site
End If
End If
End If
Next
If FoundIE = 0 Then
Set ie = CreateObject("internetexplorer.application")
ie.Visible = True
ie.navigate Site
End If
End Sub

if you have any suggestions let me know...
 
Upvote 0

Forum statistics

Threads
1,215,427
Messages
6,124,831
Members
449,190
Latest member
rscraig11

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