Can anyone provide some insite on the following questions for my macro below??
1) How can I have the below Macro password protect (lock for viewing) the VBA project in each excel file?
2) How would I create a new directory for each new day in the "enddir" variable?? Example "c:\Temp\03012005\". When I move the files, I want them to go into a directory with today's date.
3) Is there any other way to move files and over write existing files? I am using the "Name" function now, but the marco stops when it tries to move a file that is already in the "enddir".
Any help would be appreciated,
Thanks.
Sub FindClientExcelFiles()
Dim FS As Office.FileSearch
Dim vaFileName As Variant
Dim startdir
Dim enddir
Dim Foo As Object
Dim iCount As Long
Dim newname As Variant
startdir = "C:\Temp\1"
enddir = "C:\Temp\2\"
Set FS = Application.FileSearch
With FS
'Clear old search criteria
.NewSearch
'Directory to search
.LookIn = startdir
'Include sub folders in search
.SearchSubFolders = True
'Look for Excel files
.FileType = msoFileTypeExcelWorkbooks
'Doesn't matter when last modified
.LastModified = msoLastModifiedAnyTime
iCount = .Execute
For Each vaFileName In .FoundFiles
Set Foo = Workbooks.Open(vaFileName)
Foo.Save
Foo.Close
newname = Mid(vaFileName, InStrRev(vaFileName, "\") + 1)
Name vaFileName As enddir & newname
Next vaFileName
End With
End Sub
Bookmarks