Enumerating IE instances

The Windows Shell provides a powerful set of automation objects that enable you to access the file system, launch programs, and change system settings.

The Shell Windows Method creates and returns a ShellWindows object that represents a collection of all of the open windows that belong to the Shell, including Internet Explorer.

This is sample code. Add error handling and adjust to your requirements as necessary.

oShell = CREATEOBJECT("Shell.Application")
* A collection of the open windows that belong to the Shell 
oShellWindows = oShell.Windows
FOR EACH oIE IN oShellWindows 
	IF "IEXPLORE.EXE" == JUSTFNAME(UPPER(oIE.FullName))
		? oIE.LocationName
		? oIE.LocationURL
		?
	ENDIF
ENDFOR 
oShellWindows = NULL
oShell = NULL

Cool sample!

Congratulations Sergey!
I have a little observation. In my computer I got the error "OLE error code 0x80020006: Unknow name" because Outlook's window have no FullName property. I think that "IF" below solve the problem:

	IF TYPE("oIE.FullName") == [C] AND "IEXPLORE.EXE" == JUSTFNAME(UPPER(oIE.FullName))

I hope this helps.

Outlook does not show in the list

Hi Erick,

Thanks for letting me know. I run the code on PCs with Outlook 2003 and 2007 and neither showed up in the Shell windows list. Anyway, your code will fix the problem you described.

Outlook 2002

Hi Sergey,

I run the code on PC with Win XP and Outlook 2002 and the error (talked previously) occur. If I ignore the error, the result for booth commands "? oIE.LocationName" and "? oIE.LocationURL" is "outlook:Caixa%20de%20entrada". The command "? oIE.hWnd" returns "Unknow name" too. Anyway, the code that I suggested fix the problem.
Thanks for the comment!