Runtime Error '53' File Not Found?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top