List all internet explorer (or other) windows (and close them)

T

The Dude

Hello everyone,
and Merry christmas :)

I have a question regarding IE control from Excel.
Let's say a user has to close all internet explorer windows that he did not
create (or only the ones with a specific name), how could you
select/list/close them?

I have tried the getobject late binding but it does not work with IE
applications... as for AppActivate it works well but the sendkeys Alt+F4
messes up with the numlock key and sometimes bugs.

Thanks for any info ;)
T D
 
S

Steve Yandl

One method is to start a hidden instance of the Word application and take
advantage of its 'tasks' property. That will return a collection of running
applications. The 'name' property for each task returns the friendly name
(the name you would see in the title bar of the window as opposed to the
process name which might be different). Limit your search to tasks which
are visible and then use the InStr function to isolate those whose name
property gives a string containing the string "Internet Explorer". Use the
'close' method of the task to close all the IE windows and then shut down
the hidden instance of Word.

Steve
 
T

The Dude

Steve you rule!
Thanks for the tip, it works great.

Obvioulsy I had forgotten about the .quit at the end so I ended up with 15
instances of Winword, but I got to learn about the Late Binding method :)

Thanks again :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top