View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
NoodNutt NoodNutt is offline
external usenet poster
 
Posts: 221
Default What is wrong with this code?

G'day Steve

Try this

Dim OldName As String
Dim NewName As String
Dim x As String
Dim i As Integer
Dim FileYes As Integer
Dim FileNo As Integer

With Application
..ScreenUpdating = False
..EnableEvents = False
End With

Set Oldpath = "C:\MSIReportNameConvert\MSI_Input\"
Set Newpath = "C:\MSIReportNameConvert\IMDS_Output\"

With Application.FileSearch
.NewSearch
.LookIn = Oldpath
.SearchSubFolders = False 'True
.MatchTextExactly = False
.Filename = "*.*"
If .Execute(msoSortOrderDescending) 0 Then
FileYes = MsgBox ("There were " & .FoundFiles.Count & " file(s)
found.",vbOKOnly)
On Error Resume Next
For i = 1 To .FoundFiles.Count
OldName = .FoundFiles(i)

xconvention = Format(Date, "MMDDYY_")
NewName = Newpath & xconvention & OldName
Name OldName As NewName
Next i
Else
FileNo = MsgBox ("There were no files found.",vbOKOnly)
End If
End With

With Application
..ScreenUpdating = False
..EnableEvents = False
End With

End Sub

HTH
Mark.