K
Keith R
XL2003 on WinXP
I'm piecing together VBA code to identify if a target file exists, and if
so, to open it and parse it into memory and further calculations (file is
under 65K lines). The text file is created within MS Outlook using a macro
to dump an email (report from a mainframe) to the text file.
When my XL macro is run, I want to check the last saved date of the txt
file; if it was the same day (today) then the report should run without
interruption. If the txt file was saved prior to the same day, I plan to
throw an alert and allow the user to decide whether to continue (txt file is
recent enough) or cancel (to go back and find more recent data).
I can handle the logic of the date comparison and the alert box; but I'm
struggling with how to identify the last saved date of the text file. I've
appended the relevant lines of code below; what should I add as my 5th line
to pull the last saved date of this file, if it exists?
Many thanks,
Keith
Application.StatusBar = "Loading Backlog Data File"
Set mywrksht = MySheetArray(WhichFile)
LongFN = tPath & MyFileNameArray(WhichFile) & tSuffix
If Dir(LongFN) = MyFileNameArray(WhichFile) & tSuffix Then 'tells me
if file exists (?)
'something like: TxtDate = Dir(LongFN).attributes.lastsaveddate
'...code continues here
I'm piecing together VBA code to identify if a target file exists, and if
so, to open it and parse it into memory and further calculations (file is
under 65K lines). The text file is created within MS Outlook using a macro
to dump an email (report from a mainframe) to the text file.
When my XL macro is run, I want to check the last saved date of the txt
file; if it was the same day (today) then the report should run without
interruption. If the txt file was saved prior to the same day, I plan to
throw an alert and allow the user to decide whether to continue (txt file is
recent enough) or cancel (to go back and find more recent data).
I can handle the logic of the date comparison and the alert box; but I'm
struggling with how to identify the last saved date of the text file. I've
appended the relevant lines of code below; what should I add as my 5th line
to pull the last saved date of this file, if it exists?
Many thanks,
Keith
Application.StatusBar = "Loading Backlog Data File"
Set mywrksht = MySheetArray(WhichFile)
LongFN = tPath & MyFileNameArray(WhichFile) & tSuffix
If Dir(LongFN) = MyFileNameArray(WhichFile) & tSuffix Then 'tells me
if file exists (?)
'something like: TxtDate = Dir(LongFN).attributes.lastsaveddate
'...code continues here