For (1), to capture your date accurately, try this:
-
Option Compare Database
-
Option Explicit
-
-
Private Sub GetDate(strFileName as String) as Date
-
On Error GoTo EH
-
GetDate = CDate(Right(strFileName, 8))
-
Exit Sub
-
EH:
-
MsgBox Err.Number & " " & Err.Description
-
Exit Sub
-
End Sub
-
You might have to play with the syntax you send into the CDate function, because it may or may not fully recognize the text of the file name as a date.
Concerning (2) and (3), how are the files saved in the fist place? If you change how they are saved initially, i.e. if, when the files are generated, they are saved as somefilename_ccyymmdd.txt, then you are golden. Otherwise, there are ways to rename files (or copy, paste under a new name and delete).
I think your first step of capturing the date is key, though.