Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default FileSystem Object - Return Internet Address

All,

For those who like the direct approach, here is my basic question --
Is there a way to return the Internet Address for a Temporary Internet
File? Read on for more details.

I have created a recursive procedure below that accesses the Temporary
Internet Files folder and searches for a specified file to delete.
(Thanks to posts by Chip, et. al.). My code is below (and I commented
out the objFile.Delete for those who would like to simply do a copy,
paste, change the strROOTDIR constant, run “TestDelete”, and then view
the Immediate Window).

I quickly found that this method of file deletion may not be the best
way to achieve my result, as not all files from a specific website
have the same diction in the file name. If there is a way to access
the "Internet Address" of the file, then I'll be able to search for
files from a specified website and thereby delete my desired files.
Though I am using late binding below, I did add the "Microsoft
Scripting Runtime" reference to determine the properties/methods
available to a file (hence all the Debug.Print lines in my code -
partly for my own discovery purposes). There isn't a property for
"Internet Address" though, or at least I'm not aware of what it may
be.

For example, browse out to your Temporary Internet Files via the
explorer window or the browser menu:
(1) typically: C:\Documents and Settings\*folder specific to your
machine*\Local Settings\Temporary Internet Files, or
(2) via Internet Explorer: Tools | Internet Options | <General Tab |
<Browsing History Frame Settings | View Files.

You'll find that the explorer window lists a column for "Internet
Address." I'm trying to read this property. Is there a way to return
the Internet Address for a Temporary Internet File? If so, what might
the code look like?

Thanks in advance.

Matthew Herbert

Option Explicit
'CHANGE THIS TO FIT YOUR MACHINE
Public Const strROOTDIR = "C:\Documents and Settings\Matt\Local
Settings\Temporary Internet Files\"
Sub TestDelete()
DeleteFilesInDirectory strROOTDIR, "search*"
End Sub

Sub DeleteFilesInDirectory(strDirectory As String, strFileName As
String)
'---------------------------------------------------------------------
'PURPOSE: Find the files, that are Like strFileName, located in
' strRoot and delete these files.
'
'strDirectory The "root" directory. This may or may not have a "\"
' at the end of the string, e.g. C:\Documents and
Settings
' or C:\Documents and Settings\ is acceptable.
'
'strFileName The file name, or name and wildcard, to delete. This
' needs to include the wildcard if so desired, e.g.
' there is no way to know whether to look for mtna* or
' *mtna*.
'---------------------------------------------------------------------

Dim objFSO As Object
Dim objFolder As Object

'Use late binding instead of having to check/add the FSO reference
Set objFSO = CreateObject("Scripting.FileSystemObject")

'return the folder you want to work with
Set objFolder = objFSO.GetFolder(strDirectory)

'this shouldn't occur, but if the text was input incorrectly it will
If objFolder Is Nothing Then
MsgBox "No folder was found! Be sure that you entered the
argument text correctly."
Exit Sub
End If

ClearFilesInFolders objFolder, strFileName

End Sub

Sub ClearFilesInFolders(objFolder As Object, strFileName As String)
'---------------------------------------------------------------------
'PURPOSE: Searches the files within the specified folder
' (objFolder) for a match to the file name
(strFileName).
' If a match is found, the file is deleted. This
' procedure is recursive; each file within a sub folder
' of the calling folder (objFolder) is searched.
'
'objFolder The folder to search
'
'strFileName The file name to search
'---------------------------------------------------------------------

Dim objFile As Object
Dim objSubFolder As Object

'loop through each file within the folder
For Each objFile In objFolder.Files

'if the file name is like strFileName, delete the file
If objFile.Name Like strFileName Then
Debug.Print "Name :"; objFile.Name
Debug.Print "ParentFolder:"; objFile.ParentFolder
Debug.Print "Attributes :"; objFile.Attributes
Debug.Print "Date Creat :"; objFile.DateCreated
Debug.Print "Date Acces :"; objFile.DateLastAccessed
Debug.Print "Date Modif :"; objFile.DateLastModified
Debug.Print "Drive :"; objFile.Drive
Debug.Print "Path :"; objFile.Path
Debug.Print "ShortName :"; objFile.ShortName
Debug.Print "ShortPath :"; objFile.ShortPath
Debug.Print "Size :"; objFile.Size
Debug.Print "Type :"; objFile.Type
'Debug.Print "IE Address :"; objFile.InternetAddress

'objFile.Delete
End If
Next objFile

'loop through each sub folder within the calling folder
For Each objSubFolder In objFolder.SubFolders
'Debug.Print "SubFolder: "; objSubFolder.Name

'use recursion
ClearFilesInFolders objSubFolder, strFileName
Next objSubFolder

End Sub
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 to put an internet-address in Excel just as a text-field? Tomas Barth New Users to Excel 3 May 13th 06 05:36 PM
Visual Basic in Excel to Control Internet Explorer Object RST Excel Programming 0 February 21st 06 10:25 PM
Invalid internet address [email protected] Excel Programming 1 January 17th 06 12:27 PM
Filesystem again Alvin Hansen[_2_] Excel Programming 3 January 31st 05 07:55 PM
Internet explorer object questions Tim Coddington Excel Programming 2 December 18th 04 01:59 PM


All times are GMT +1. The time now is 12:00 AM.

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

About Us

"It's about Microsoft Excel"