Discussion Locked

How to display Excel file modify date?

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How can you display an Excel file's modification date (i.e. save date) in a cell of said file? Word has a field code for SaveDate, but I can't find anything like it in Excel. I haven't been able to find anything yet in VBA code to handle it either.

10 replies

by peyison

You can get to it in VBA from the BuiltInDocumentProperties property:

msgbox ActiveWorkbook.BuiltinDocumentProperties("last save time")

Hope this helps.

by gmreed

Thanks for the fast reply. Unfortunately, it is not working for me. It gives error msg: Run-time error '-2147467259 (800040005)': Automation error Unspecified error.
I tested this by creating a button with macro with the specified msgbox text to click to display the message box.
I am using Excel 97.
Thanks for your assistance!

by gmreed

Thanks for the fast reply. Unfortunately, it is not working for me. It gives error msg: Run-time error '-2147467259 (800040005)': Automation error Unspecified error.
I am using Excel 97.

by peyison

Did you save your workbook first? These properties are kind of flaky - don't seem to have very good error handling to them.

by gmreed

Yes, I did save it. I tried making a change and resaving in case it was something like a modified date instead of a created date. I tried making the property into a dimension - failed as string, failed as text. I used the sample code in Help thatlists the properties' names to verify spacing/spelling. No luck.

by peyison

Try using a modified version of the example in help:

Sub test()
Dim rw As Integer
Dim p As DocumentProperty

On Error Resume Next
rw = 1
Worksheets(1).Activate
For Each p In ActiveWorkbook.BuiltinDocumentProperties
Cells(rw, 1).Value = p.Name
Cells(rw, 2).Value = p.Value
rw = rw + 1
Next

End Sub

I only get values for 6 of the properties (out of 30). Check the properties of your workbook (File -> Properties) - look on the General or Statistics tabs - is there a date in the "Modified:" property?

Like I said - very flaky.

by sankulpune

Hello,

In the beforeSave event of the workbook, insert following code:

ActiveWorkbook.BuiltinDocumentProperties("Last save time") = now

Paste the following macro in personal.xls

sub PrintlastSaveTime()

Selection = ActiveWorkbook.BuiltinDocumentProperties("Last save time")

End Sub

Save the workbook, select a cell and run the macro. You will see the details of the last save in the selected cell.

I would be glad to furnish any more details that would help solving the problem.

Your feedback will be highly appreciated.

with regards,

SanganakSakha,
Simple And Effective Solutions To Small Problems, No QuickFixes.

This discussion is closed to new replies.