ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting at Windows File Created date with VBA (https://www.excelbanter.com/excel-programming/373633-getting-windows-file-created-date-vba.html)

Neal Zimm

Getting at Windows File Created date with VBA
 

In my app I use this slightly modified, (from a recorded macro) code
to save a workbook and create the standard backup
"Backup of ????????????.xlk" file name.

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=FullNa, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=True
Application.DisplayAlerts = True

In the open event, if the "Backup of " workbook is opened, I'd like to
show the DATE and TIME the backup was made. I don't know how to get at the
windows 'file modified' or created time stamp.

If someone could provide some code to get at this date, I'd appreciate
it. The FullNa var above contains the full path and the workbook name
of the original and my testing show the backup goes to the same folder.

In the app, I have a hidden worksheet, (DataStore) that holds
other indicative data about the workbook. If I can't "get at" the windows
date, is it a bad idea to store the Now time in my DataStore ?

I use a function I develped to search the DataStore and retrieve values
based on a home-grown 'data-key'


Thanks,
Neal Z.
--


moon[_7_]

Getting at Windows File Created date with VBA
 
Use the filesystemobject:


Public Function GetDateModified(ByVal strFileName As String) As Date

Dim fso, f

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(strFileName)

GetDateModified = f.DateLastModified

Set f = Nothing
Set fso = Nothing

End Function



"Neal Zimm" schreef in bericht
...

In my app I use this slightly modified, (from a recorded macro) code
to save a workbook and create the standard backup
"Backup of ????????????.xlk" file name.

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=FullNa, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=True
Application.DisplayAlerts = True

In the open event, if the "Backup of " workbook is opened, I'd like to
show the DATE and TIME the backup was made. I don't know how to get at the
windows 'file modified' or created time stamp.

If someone could provide some code to get at this date, I'd appreciate
it. The FullNa var above contains the full path and the workbook name
of the original and my testing show the backup goes to the same folder.

In the app, I have a hidden worksheet, (DataStore) that holds
other indicative data about the workbook. If I can't "get at" the windows
date, is it a bad idea to store the Now time in my DataStore ?

I use a function I develped to search the DataStore and retrieve values
based on a home-grown 'data-key'


Thanks,
Neal Z.
--




Stefi

Getting at Windows File Created date with VBA
 
See FileDateTime function in VBA Help!

Regards,
Stefi


€žNeal Zimm€ť ezt Ă*rta:


In my app I use this slightly modified, (from a recorded macro) code
to save a workbook and create the standard backup
"Backup of ????????????.xlk" file name.

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=FullNa, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=True
Application.DisplayAlerts = True

In the open event, if the "Backup of " workbook is opened, I'd like to
show the DATE and TIME the backup was made. I don't know how to get at the
windows 'file modified' or created time stamp.

If someone could provide some code to get at this date, I'd appreciate
it. The FullNa var above contains the full path and the workbook name
of the original and my testing show the backup goes to the same folder.

In the app, I have a hidden worksheet, (DataStore) that holds
other indicative data about the workbook. If I can't "get at" the windows
date, is it a bad idea to store the Now time in my DataStore ?

I use a function I develped to search the DataStore and retrieve values
based on a home-grown 'data-key'


Thanks,
Neal Z.
--


Tom Ogilvy

Getting at Windows File Created date with VBA
 
I would guess both the methods suggested will not give you the time of the
last save since that is reset when the file is opened. If so, then I don't
see any problem with putting a hard coded date and time in your hidden sheet
just before you save it.

--
Regards,
Tom Ogilvy


"Neal Zimm" wrote:


In my app I use this slightly modified, (from a recorded macro) code
to save a workbook and create the standard backup
"Backup of ????????????.xlk" file name.

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=FullNa, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=True
Application.DisplayAlerts = True

In the open event, if the "Backup of " workbook is opened, I'd like to
show the DATE and TIME the backup was made. I don't know how to get at the
windows 'file modified' or created time stamp.

If someone could provide some code to get at this date, I'd appreciate
it. The FullNa var above contains the full path and the workbook name
of the original and my testing show the backup goes to the same folder.

In the app, I have a hidden worksheet, (DataStore) that holds
other indicative data about the workbook. If I can't "get at" the windows
date, is it a bad idea to store the Now time in my DataStore ?

I use a function I develped to search the DataStore and retrieve values
based on a home-grown 'data-key'


Thanks,
Neal Z.
--


Neal Zimm

Getting at Windows File Created date with VBA
 
Thanks for the prompt response.
--
Neal Z


"moon" wrote:

Use the filesystemobject:


Public Function GetDateModified(ByVal strFileName As String) As Date

Dim fso, f

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(strFileName)

GetDateModified = f.DateLastModified

Set f = Nothing
Set fso = Nothing

End Function



"Neal Zimm" schreef in bericht
...

In my app I use this slightly modified, (from a recorded macro) code
to save a workbook and create the standard backup
"Backup of ????????????.xlk" file name.

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=FullNa, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=True
Application.DisplayAlerts = True

In the open event, if the "Backup of " workbook is opened, I'd like to
show the DATE and TIME the backup was made. I don't know how to get at the
windows 'file modified' or created time stamp.

If someone could provide some code to get at this date, I'd appreciate
it. The FullNa var above contains the full path and the workbook name
of the original and my testing show the backup goes to the same folder.

In the app, I have a hidden worksheet, (DataStore) that holds
other indicative data about the workbook. If I can't "get at" the windows
date, is it a bad idea to store the Now time in my DataStore ?

I use a function I develped to search the DataStore and retrieve values
based on a home-grown 'data-key'


Thanks,
Neal Z.
--





Neal Zimm

Getting at Windows File Created date with VBA
 
Thanks for the prompt response. On something like this, I agree that I'm more
comfortable with it under "my" control.
--
Neal Z


"Tom Ogilvy" wrote:

I would guess both the methods suggested will not give you the time of the
last save since that is reset when the file is opened. If so, then I don't
see any problem with putting a hard coded date and time in your hidden sheet
just before you save it.

--
Regards,
Tom Ogilvy


"Neal Zimm" wrote:


In my app I use this slightly modified, (from a recorded macro) code
to save a workbook and create the standard backup
"Backup of ????????????.xlk" file name.

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=FullNa, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=True
Application.DisplayAlerts = True

In the open event, if the "Backup of " workbook is opened, I'd like to
show the DATE and TIME the backup was made. I don't know how to get at the
windows 'file modified' or created time stamp.

If someone could provide some code to get at this date, I'd appreciate
it. The FullNa var above contains the full path and the workbook name
of the original and my testing show the backup goes to the same folder.

In the app, I have a hidden worksheet, (DataStore) that holds
other indicative data about the workbook. If I can't "get at" the windows
date, is it a bad idea to store the Now time in my DataStore ?

I use a function I develped to search the DataStore and retrieve values
based on a home-grown 'data-key'


Thanks,
Neal Z.
--



All times are GMT +1. The time now is 10:39 AM.

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