E
et10yl
Hi,
I have an Excel macro that is supposed to go through all the files in a
directory and change the extensions from DOC to DAT. It was working at
first, but now it seems that I keep getting the File Not Found error (Runtime
Error 53) when I try to run the macro, even though the file to be renamed is
explicitly there in the folder.
What am I missing here?
Thanks in advance!
Public Sub ChangeFileExtensions()
Dim strDir As String
strDir = ThisWorkbook.Path
Call ProcessFiles(Dir(strDir & "\*.Doc"))
Do ' LOOP THRU ALL D06 IN JUNKFOLDER
Loop Until Not ProcessFiles(Dir)
End Sub
Function ProcessFiles(SourceFile)
On Error GoTo NoFiles
oldName = SourceFile
newName = Left(SourceFile, (Len(SourceFile) - 3)) & "DAT"
Name oldName As newName
Exit Function
NoFiles:
ProcessFiles = False
End Function
I have an Excel macro that is supposed to go through all the files in a
directory and change the extensions from DOC to DAT. It was working at
first, but now it seems that I keep getting the File Not Found error (Runtime
Error 53) when I try to run the macro, even though the file to be renamed is
explicitly there in the folder.
What am I missing here?
Thanks in advance!
Public Sub ChangeFileExtensions()
Dim strDir As String
strDir = ThisWorkbook.Path
Call ProcessFiles(Dir(strDir & "\*.Doc"))
Do ' LOOP THRU ALL D06 IN JUNKFOLDER
Loop Until Not ProcessFiles(Dir)
End Sub
Function ProcessFiles(SourceFile)
On Error GoTo NoFiles
oldName = SourceFile
newName = Left(SourceFile, (Len(SourceFile) - 3)) & "DAT"
Name oldName As newName
Exit Function
NoFiles:
ProcessFiles = False
End Function