Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

InternetExplorer child windows getobject shellwindows

Status
Not open for further replies.

JL42

Technical User
Jun 23, 2003
12
US
I was trying to work on a pop-up blocker.
Createobject gives you an object that you can trap the newwindow2 event, but you can't cancel it because VBScript uses variants, not an actual boolean.
getobject fails, in every permutation I tried. It won't accept a missing path, despite MSDN documentation. It did work in VBA leaving the path as a missing parameter, but it has no way of returning anything other than the first window opened, and no children windows collections. WMI won't do it either, it only returns the applications IEXPLORE.EXE, which hosts multiple windows in a single instance.

But fear not! and answer has been found, that gives you an object for each window with access to the document property within each.
Here is a short demo script.vbs
=======================================
dim objShell, objShellWindows, i

set objShell = createObject("Shell.Application")
set objShellWindows = objShell.Windows

if (not objShellWindows is nothing) then
for i = 0 to objShellWindows.count - 1
msgbox objShellWindows.Item(i).locationurl
next
end if

set objShellWindows = nothing
set objShell = nothing

'thanks to member billchris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top