How do I clear Internet Explorer with Excel VBA?

Captain Smith

Active Member
Joined
Feb 28, 2003
Messages
324
I have a need to clear Internet Explorer temp files, cookies, history. How do I do this in Excel VBA? I need it to work in both 2003 and 2007.

Thank you!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Need to find where the cookies etc. are stored then have code like this :-
Code:
'=============================================================================
'- DELETE COOKIES : VBA CODE
'=============================================================================
Sub DELETE_COOKIES()
    Dim MyFolder As String
    '-------------------------------------------------------------------------
    '- Cookie folder
    MyFolder = "C:\Users\Brian\AppData\Roaming\Microsoft\Windows\Cookies\"
    '- Delete all cookies
    Kill MyFolder & "*.txt"           ' use this with care
    '-------------------------------------------------------------------------
    '- Windows Temp
    MyFolder = "C:\WINDOWS\Temp\"
    '- Delete all cookies
    Kill MyFolder & "*.tmp"           ' use this with care
    '-------------------------------------------------------------------------
    MsgBox ("Done")
End Sub
'=============================================================================

I find it more convenient to run a batch file - it saves opening Excel :-
Code:
 Rem '=============================================================================
 Rem '- DELETE COOKIES : MSDOS BATCH FILE
 Rem '- This is an ordinary Notepad text file with suffix .bat instead of .txt
 Rem '- Can be run from a shortcut
 Rem '=============================================================================
    Rem turn off unwanted messages
@ECHO OFF
CLS
Rem -----------------------------------------------------------------------------------------------------------
ECHO ROAMING COOKIES
    Rem change to required folder
C:    
Rem Cookies  --------------------------------------------------------------------------------------------
CD C:\Users\Brian\AppData\Roaming\Microsoft\Windows\Cookies
    Rem delete all .txt files 
DEL *.txt
Rem Temp Files ------------------------------------------------------------------------------------------
ECHO TEMP FILES
CD C:\WINDOWS\TEMP
DEL *.tmp
Rem --------------------------------------------------------------------------------------------------------------
    Rem stop to show results ("press any key ..")
PAUSE
 
Upvote 0
Why do you need to do this using Excel VBA?

Doesn't IE have built-in options for this? And aren't there apps, some free, out there that can do it too?:)
 
Upvote 0

Forum statistics

Threads
1,215,727
Messages
6,126,519
Members
449,316
Latest member
sravya

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