Error message on "last saved date"-VBA code

Tigron

New Member
Joined
Jun 2, 2023
Messages
21
Office Version
  1. 2021
Platform
  1. MacOS
Hello community,
I tried using the search function here in the forums and I reviewed quite a few tutorials online. I even asked ChatGPT, but in all cases I didn't get an answer...
I want to display the date of the last time my Excel file was saved. To do so, I used the following VBA code:
VBA Code:
Function LastSaved()
    Application.Volatile
    LastSaved = FileDateTime(ActiveWorkbook.FullName)
End Function

In the desired cell I entered
Excel Formula:
=LastSaved()
I get the following error message: #NAME?. I re-checked the name twice. But it's definitely correct.
Any ideas what is going wrong?

P.S.: I am using the macOS version of Excel 2021. Could that be an/the issue?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi Micron,
thank you for the fast reply. The more I work with Excel on macOS the more frustrated I get. :mad:
Does anybody with a Mac have a solution to my problem? I am a complete noob to VBA in Excel and could use some help.

Thanks in advance!
 
Upvote 0
Isn't that code a solution for you?
I'm afraid, I don't know how to implement what he was writing about. I am a complete noob to VBA.
 
Upvote 0
Nobody have an idea? The proposed solution isn't what I was looking for. Besides, it also contains AppleScript, which I don't think applies to my situation, either.
I wasn't able to find anything else on the internet.
 
Upvote 0
I found a semi-solution on stackoverflow and altered it with the help of ChatGPT now the code will display the date and time like so: Wednesday, 14. June 2023 17:53:59 Of course you can change the format to your likings. Unfortunately, you need to press "update data" in order for it to show the current last save time. I couldn't find another way to circumvent this issue.

VBA Code:
Function LastSavedTimeStamp() As String
    Application.Volatile
    LastSavedTimeStamp = Format(ActiveWorkbook.BuiltinDocumentProperties("Last Save Time"), "dddd, dd. mmmm yyyy hh:mm:ss")
End Function

For VBA-noobs like me ;): you need to add the following formula into the cell where the date should be displayed:
Excel Formula:
=LastSavedTimeStamp()

Cheers!
 
Upvote 0
Solution

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top