Application.FileSearch didn't work in Office 2007 (It has been deprecated from Office 2007) and hence it doesn't work in Office 2010 either. It will throw Run-time Errror 445 Object doesn't support this action
There are some good work-arounds for this:
1. FileSystemObject
2. Dir Function
For a lively discussion please have a look at http://social.msdn.microsoft.com/Forums/en/isvvba/thread/a450830d-4fc3-4f4e-aee2-03f7994369d6
Excel 2010 Application.FileSearch Error, Excel 2007 Application.FileSearch Error
For i = 1 To fileCount
ReplyDeleteDim fso Set fso = CreateObject("Scripting.FileSystemObject")
'fso.CopyFile "C:\Yash\MyFiles$\32\*.doc", "C:\Yash\MyFiles$\32\backup"
Set fso = Nothing
Kill sPath & fileNames(i)
Next i
I use the above code lines to copy the files from a path to a back up location, It is taking too long. How can I make it quick? this is happening especially when I use a network path.
Here is a way to do it Yaswi - http://vbadud.blogspot.com/2011/05/how-to-xcopy-files-using-vba.html
ReplyDeleteYou can use
'Kill "c:\temp\*.*"
to delete all files in a folder; but be cautious in doing so. Atleast get the file count and size of source and destination folders before emptying
I have my major programs do a daily self-backup so that if the user mistakenly deletes a wrong record, it can be recovered in a backup file. FileSearch allowed me to delete older backup files so as not to have too many. FileSearch should not have been removed.
ReplyDelete