Close all IE Browser windows with VBA

tx12345

Board Regular
Joined
Aug 28, 2006
Messages
165
Hi

I have been using

ie.Quit
Set IE = Nothing

but that only closes one browser window. however, sometimes a pop up window shows up and is still left on the desktop. just wondering if there is a command to say

'ie.closeall'

or something like that

tx
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Well there is always NateO's sledgehammer... But I would use this with caution, it will kill ALL internet explorer windows:

Code:
Option Explicit
Sub IE_Sledgehammer()
    Dim objWMI As Object, objProcess As Object, objProcesses As Object
    Set objWMI = GetObject("winmgmts://.")
    Set objProcesses = objWMI.ExecQuery( _
        "SELECT * FROM Win32_Process WHERE Name = 'iexplore.exe'")
    For Each objProcess In objProcesses
        Call objProcess.Terminate
    Next
    Set objProcesses = Nothing: Set objWMI = Nothing
End Sub
 
Upvote 0
Nice one Oorang! All kinds of web-scraping activities get bogged down as IE takes more and more resources...an occasional loop to "IE_Slegehammer" and the problem is solved. Thank you!
 
Upvote 0
I see credit is due to NateO originally...good one. One thing that happens if you are looping through many times is that a program will hang as it seems unable to restart IE. I put an: Application.Wait (Now + Time Value("0:00:03")) line at the end of IE+Sledgehammer and it seems to have resolved this problem completely.
 
Upvote 0
The Sledgehammer kills the IE process but then my VBA code just hangs after that. How do I make it loop?

With ie
.Visible = False

For j = 2 To i

If j = 4 Then
Call IE_Sledgehammer
End If
.navigate "http://google.com/gp/product/" & ThisWorkbook.Sheets(1).Cells(j, 1)
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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