Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Listing Temporary Internet Files

Why is it not possible to list the contents of the "Temporary Internet
Files" folder using the DIR function in Excel VBA ?

DIR invariably returns a null string even though there are many files in
that folder.

Appreciate any help.

AP


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default Listing Temporary Internet Files

Alan,

Not quite as simple as it sounds. I personally don't know what on earth they
were doing when they came up with this amazing cache scheme for IE6, which I
presume is what you are working with. Anyway, this gets files into a new
workbook. Note, it's extracted from a vb routine I wrote a while back so it
uses vb constants but they seem to work fine on excel xp.

Option Explicit

Sub GetIECacheFiles()

Dim vDirList As Variant
Dim vDirName As Variant
Dim lFileCount As Long
Dim strRoot As String
Dim strName As String
Dim strFilter As String
Dim strFind As String

Workbooks.Add

strFilter = InputBox("If you wish to filter for a particular file type
please enter the extension")

strRoot = "C:\Documents and Settings\UserName\Local Settings\Temporary
Internet Files\Content.IE5\"

Call GetDirs(strRoot, vDirList)
lFileCount = 1

For Each vDirName In vDirList

strFind = vDirName & "\"
strFind = strFind & IIf(strFilter < "", "*." & strFilter, "*.*")
strName = Dir(strFind, vbDirectory + vbHidden + vbSystem)

Do While strName < ""

If strName < "." And strName < ".." Then

If (GetAttr(vDirName & strName) And vbDirectory) < vbDirectory
Then

Cells(lFileCount, 1).Value = vDirName
Cells(lFileCount, 2).Value = strName
lFileCount = lFileCount + 1

End If

End If

strName = Dir

Loop

Next vDirName

End Sub

Private Sub GetDirs(strRoot, vDirList)
Dim strName As String

strName = Dir(strRoot, vbDirectory + vbHidden + vbSystem)
Do While strName < ""
If strName < "." And strName < ".." Then
If (GetAttr(strRoot & strName) And vbDirectory) = vbDirectory Then
If IsEmpty(vDirList) Then
ReDim vDirList(0)
Else
ReDim Preserve vDirList(0 To UBound(vDirList) + 1)
End If
On Error GoTo 0
vDirList(UBound(vDirList)) = strRoot & strName & "\"
End If
End If
strName = Dir
Loop
End Sub

HTH,

Robin Hammond
www.enhanceddatasystems.com

"Alan Phang" wrote in message
...
Why is it not possible to list the contents of the "Temporary Internet
Files" folder using the DIR function in Excel VBA ?

DIR invariably returns a null string even though there are many files in
that folder.

Appreciate any help.

AP




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Listing Temporary Internet Files

Robin,

Thanks very much - it worked very nicely.

I'm not familiar with VB (as opposed to Excel VBA) - would greatly
appreciate if you could show me how I could modify the code to *list* and
*delete* the files immediately within the "Temporary Internet Files" folder
itself.

Thanks for your help. Appreciate it.

Alan


"Robin Hammond" wrote in message
...
Alan,

Not quite as simple as it sounds. I personally don't know what on earth

they
were doing when they came up with this amazing cache scheme for IE6, which

I
presume is what you are working with. Anyway, this gets files into a new
workbook. Note, it's extracted from a vb routine I wrote a while back so

it
uses vb constants but they seem to work fine on excel xp.

Option Explicit

Sub GetIECacheFiles()

Dim vDirList As Variant
Dim vDirName As Variant
Dim lFileCount As Long
Dim strRoot As String
Dim strName As String
Dim strFilter As String
Dim strFind As String

Workbooks.Add

strFilter = InputBox("If you wish to filter for a particular file type
please enter the extension")

strRoot = "C:\Documents and Settings\UserName\Local Settings\Temporary
Internet Files\Content.IE5\"

Call GetDirs(strRoot, vDirList)
lFileCount = 1

For Each vDirName In vDirList

strFind = vDirName & "\"
strFind = strFind & IIf(strFilter < "", "*." & strFilter, "*.*")
strName = Dir(strFind, vbDirectory + vbHidden + vbSystem)

Do While strName < ""

If strName < "." And strName < ".." Then

If (GetAttr(vDirName & strName) And vbDirectory) <

vbDirectory
Then

Cells(lFileCount, 1).Value = vDirName
Cells(lFileCount, 2).Value = strName
lFileCount = lFileCount + 1

End If

End If

strName = Dir

Loop

Next vDirName

End Sub

Private Sub GetDirs(strRoot, vDirList)
Dim strName As String

strName = Dir(strRoot, vbDirectory + vbHidden + vbSystem)
Do While strName < ""
If strName < "." And strName < ".." Then
If (GetAttr(strRoot & strName) And vbDirectory) = vbDirectory Then
If IsEmpty(vDirList) Then
ReDim vDirList(0)
Else
ReDim Preserve vDirList(0 To UBound(vDirList) + 1)
End If
On Error GoTo 0
vDirList(UBound(vDirList)) = strRoot & strName & "\"
End If
End If
strName = Dir
Loop
End Sub

HTH,

Robin Hammond
www.enhanceddatasystems.com

"Alan Phang" wrote in message
...
Why is it not possible to list the contents of the "Temporary Internet
Files" folder using the DIR function in Excel VBA ?

DIR invariably returns a null string even though there are many files in
that folder.

Appreciate any help.

AP






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default Listing Temporary Internet Files

After this line

lFileCount = lFileCount + 1

Add

On Error Resume Next
If strName < "desktop.ini" Then Kill vDirName & strName
On Error GoTo 0

Robin Hammond
www.enhanceddatasystems.com

"Alan Phang" wrote in message
...
Robin,

Thanks very much - it worked very nicely.

I'm not familiar with VB (as opposed to Excel VBA) - would greatly
appreciate if you could show me how I could modify the code to *list* and
*delete* the files immediately within the "Temporary Internet Files"

folder
itself.

Thanks for your help. Appreciate it.

Alan


"Robin Hammond" wrote in message
...
Alan,

Not quite as simple as it sounds. I personally don't know what on earth

they
were doing when they came up with this amazing cache scheme for IE6,

which
I
presume is what you are working with. Anyway, this gets files into a new
workbook. Note, it's extracted from a vb routine I wrote a while back so

it
uses vb constants but they seem to work fine on excel xp.

Option Explicit

Sub GetIECacheFiles()

Dim vDirList As Variant
Dim vDirName As Variant
Dim lFileCount As Long
Dim strRoot As String
Dim strName As String
Dim strFilter As String
Dim strFind As String

Workbooks.Add

strFilter = InputBox("If you wish to filter for a particular file type
please enter the extension")

strRoot = "C:\Documents and Settings\UserName\Local Settings\Temporary
Internet Files\Content.IE5\"

Call GetDirs(strRoot, vDirList)
lFileCount = 1

For Each vDirName In vDirList

strFind = vDirName & "\"
strFind = strFind & IIf(strFilter < "", "*." & strFilter, "*.*")
strName = Dir(strFind, vbDirectory + vbHidden + vbSystem)

Do While strName < ""

If strName < "." And strName < ".." Then

If (GetAttr(vDirName & strName) And vbDirectory) <

vbDirectory
Then

Cells(lFileCount, 1).Value = vDirName
Cells(lFileCount, 2).Value = strName
lFileCount = lFileCount + 1

End If

End If

strName = Dir

Loop

Next vDirName

End Sub

Private Sub GetDirs(strRoot, vDirList)
Dim strName As String

strName = Dir(strRoot, vbDirectory + vbHidden + vbSystem)
Do While strName < ""
If strName < "." And strName < ".." Then
If (GetAttr(strRoot & strName) And vbDirectory) = vbDirectory

Then
If IsEmpty(vDirList) Then
ReDim vDirList(0)
Else
ReDim Preserve vDirList(0 To UBound(vDirList) + 1)
End If
On Error GoTo 0
vDirList(UBound(vDirList)) = strRoot & strName & "\"
End If
End If
strName = Dir
Loop
End Sub

HTH,

Robin Hammond
www.enhanceddatasystems.com

"Alan Phang" wrote in message
...
Why is it not possible to list the contents of the "Temporary Internet
Files" folder using the DIR function in Excel VBA ?

DIR invariably returns a null string even though there are many files

in
that folder.

Appreciate any help.

AP








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I open temporary internet files mdoyer Excel Discussion (Misc queries) 3 October 12th 09 07:41 AM
Network Files creating temporary files Dave Weastec Excel Discussion (Misc queries) 0 October 3rd 08 02:26 PM
temporary directory files IMJQT Excel Discussion (Misc queries) 1 April 9th 08 12:30 AM
temporary files to the recording of Excel guillaume Setting up and Configuration of Excel 0 June 27th 06 11:50 AM
Why does Excel saves all my files as temporary files? Arija Excel Discussion (Misc queries) 2 December 7th 04 11:38 PM


All times are GMT +1. The time now is 11:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"