File Save Properties

D

Daniel Jones

Does anyone know how to access the properties for the last date/time
an .xls file was saved within VBA?

Thanks.

D
 
O

OssieMac

Hi Daniel,

Dim dateLastSave As Date

dateLastSave = FileDateTime(ThisWorkbook.Name)

MsgBox dateLastSave


Note: ThisWorkbook.Name can be replaced with the name of the workbook in
double quotes and it can be any other workbook as well as the current one.
However, will need to include the path if it is not in the current default
path.

Example (In current default path):
dateLastSave = FileDateTime("My Other workbook.xls")
 
L

Logos

Hi Daniel,

Dim dateLastSave As Date

dateLastSave =FileDateTime(ThisWorkbook.Name)

MsgBox dateLastSave

Note: ThisWorkbook.Name can be replaced with the name of the workbook in
double quotes and it can be any other workbook as well as the current one..
However, will need to include the path if it is not in the current default
path.

Example (In current default path):
dateLastSave =FileDateTime("My Other workbook.xls")

Thanks for your help! Sorry, I'm a bit new to this. Which path is
the current default path?

I would like to use the code below to get the FileDateTime for the
active workbook. It doesn't seem like I need to change the default
directory, but how would you go about doing this if needed?

Sub TestFileSave()
Dim dateLastSave As Date
Dim strPath As String
strPath = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name

dateLastSave = FileDateTime(strPath)
MsgBox dateLastSave
End Sub

Thanks!

D
 
D

Daniel Jones

Hi Daniel,

Dim dateLastSave As Date

dateLastSave = FileDateTime(ThisWorkbook.Name)

MsgBox dateLastSave

Note: ThisWorkbook.Name can be replaced with the name of the workbook in
double quotes and it can be any other workbook as well as the current one..
However, will need to include the path if it is not in the current default
path.

Example (In current default path):
dateLastSave = FileDateTime("My Other workbook.xls")

Thanks for your help! Sorry, I'm a bit new to this. Which path is
the current default path?

I would like to use the code below to get the FileDateTime for the
active workbook. It doesn't seem like I need to change the default
directory, but how would you go about doing this if needed?

Sub TestFileSave()
Dim dateLastSave As Date
Dim strPath As String
strPath = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name

dateLastSave = FileDateTime(strPath)
MsgBox dateLastSave
End Sub

Thanks!

D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top