ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Runtime Error '53' File Not Found? (https://www.excelbanter.com/excel-discussion-misc-queries/120282-runtime-error-53-file-not-found.html)

et10yl

Runtime Error '53' File Not Found?
 
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



All times are GMT +1. The time now is 02:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com