Tom,
I follow what you say and would probably be an easier way of doing it,
however the users that would be doing this are 'little old ladies' with very
basic skill.
I have attached the code that I have managed to put together with help from
others, which works by going through each workbook and asking the delete
question.
Sub DeleteFiles()
Dim FSO As Object
Dim sFolder As String
Dim fldr As Object
Dim Folder As Object
Dim file As Object
Dim Files As Object
'Dim LastName As String
'Dim FirstName As String
'Dim Temp
'Temp = Split(sFolder)
Set FSO = CreateObject("Scripting.FileSystemObject")
sFolder = "W:\Accounts\A_Site Daily Bankings\Live - to be posted"
If sFolder < "" Then
Set Folder = FSO.GetFolder(sFolder)
Set Files = Folder.Files
For Each file In Files
If file.Type = "Microsoft Excel Worksheet" Then
If InStr(1, file.Name, findloc) 0 Then
resp = MsgBox("Do you want to delete file " & file.Name,
vbYesNo, "Delete Files")
If resp = vbYes Then file.DELETE
End If
End If
Next file
End If ' sFolder < ""
Set FSO = Nothing
End Sub
but again, I only want to see the oldest duplicate (so it can be deleted) and
I can't seem to write the code to even tell if the file is duplicted ? ie
first name and last name.
Cheers matey
David
Tom Ogilvy wrote:
as you gather your list of file names, you can parse out the information you
need as shown in the is demo from the immediate window:
s = "SiteName Banking 09Mar2006_152598.xls"
? s
SiteName Banking 09Mar2006_152598.xls
? left(s,17)
SiteName Banking
? mid(s,18,9)
09Mar2006
? Mid(s,27,255)
_152598.xls
to me, however, it would seem easiest to write you filelist to a worksheet.
then sort the worksheet and delete any files you want to keep (from the
list). then loop through the list of names and delete them
for each cell in Range("A1",Range("A1").End(xldown))
Kill cell
Next
Thanks for your reply Tom,
[quoted text clipped - 27 lines]
Anybody any idea's?,
--
Message posted via
http://www.officekb.com