Temporary Internet Files

J

johnc3640

I have recently upgraded to Vista and Office 2007. I have an automated Excel
worksheet that collects a lot of data from the internet using web queries.
However, with Vista my temporary internet folder becomes full and the web
queries stop working. I can correct the problem by deleting those files in
IE (this is not a practical solution because my prior automated update
process needs continual live interface). Is anyone aware of a VB script that
might solve this problem - ie deleting temporary internet files?

I have tried this one but it doesnt work :

Sub Killfile()
Dim MyFile As String 'This line of code is optional
MyFile = "c:\Users\*user*\AppData\Local\Microsoft\Windows\Temporary Internet
Files\*.htm"
mypath = CurDir
Kill MyFile
End Sub
 
C

Chip Pearson

Try the following code:


Sub DeleteTempFolders()
Dim FSO As Object
Dim NumDeleted As Long
Dim NumSkipped As Long
Dim FF As Object
'>>>> CHANGE VALUE OF FOLDERNAME
Const FOLDERNAME = _
"C:\Users\Pearson\AppData\Local\Microsoft\Windows\Temporary Internet
Files"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FF = FSO.GetFolder(FOLDERNAME)
ClearFolder FF, NumDeleted, NumSkipped
Debug.Print "Number Deleted: " & CStr(NumDeleted), "Number Skipped: " &
CStr(NumSkipped)
End Sub

Sub ClearFolder(WhatFolder As Object, NumDeleted As Long, NumSkipped As
Long)
Dim SubF As Object
Dim F As Object

On Error Resume Next
For Each F In WhatFolder.Files
Err.Clear
F.Delete
If Err.Number = 0 Then
NumDeleted = NumDeleted + 1
Else
NumSkipped = NumSkipped + 1
End If
Next F

For Each SubF In WhatFolder.SubFolders
ClearFolder SubF, NumDeleted, NumSkipped
Next SubF
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
C

Chip Pearson

It worked for me. It might be a permissions issue. What exactly leads you to
believe that it doesn't work? Does the code blow up, is there a compiler
error? Just what does "doesn't work" mean?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 

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