Just to comment, CMP's code does NOT work for me unless I make it Uppercase. It does not work otherwise.
Code:
If Right(objWindow.FullName, 12) = UCase("iexplore.exe") Then
Debug.Print objWindow.LocationURL
End If
Further, with Tabs in IE 7, the following returns the URL for each Tab,
without the use of Right(objWindow.FullName, 12).
Code:
Sub GetURLFromIE()
Dim objShell As Object
Dim objWindows As Object, objWindow As Object
Set objShell = CreateObject("Shell.Application")
Set objWindows = objShell.Windows
For Each objWindow In objWindows
Debug.Print objWindow.LocationURL
Next
Set objWindow = Nothing
Set objWindows = Nothing
Set objShell = Nothing
End Sub
In fact, at least on my system,
Right(objWindow.FullName, 12)
seems to ignore all Office and other Windows application (EXCEPT explorer.exe). I have the following applications open:
Outlook
Powerpoint -
two presentation files
PolyView - a graphics app
MS Word -
three documents open
IE 7 -
three Tabs with URL
Windows Explorer
The result of...
Code:
Sub GetURLFromIE_2()
Dim objShell As Object
Dim objWindows As Object, objWindow As Object
Set objShell = CreateObject("Shell.Application")
Set objWindows = objShell.Windows
For Each objWindow In objWindows
[b]Debug.Print objWindow.FullName
Next
Set objWindow = Nothing
Set objWindows = Nothing
Set objShell = Nothing
End Sub
C:\Program Files\Internet Explorer\IEXPLORE.EXE
C:\Program Files\Internet Explorer\IEXPLORE.EXE
C:\Program Files\Internet Explorer\IEXPLORE.EXE
C:\WINNT\Explorer.EXE
All the other application windows are ignored.
Gerry