How do I add if exists to this code? If the source file is not found there should be a msgbox stating "not found" or else it should complete.
Dim SourceFile, DestinationFile
SourceFile = "myfile.txt" ' Define source file name.
x = InStr(1, SourceFile, ".")
TempStr1 = Left(SourceFile, x - 1)
TempStr2 = Right(SourceFile, Len(SourceFile) - x + 1)
NewName = TempStr1 & Format(Now, "ddmmyyyyhhmm") & TempStr2
SourceFile = "C:\pathoflogfile\" & SourceFile
DestinationFile = "R:\yourpathnamehere\" & NewName
Name SourceFile As DestinationFile