Custom Function to display "last save time"

Kemidan2014

Board Regular
Joined
Apr 4, 2022
Messages
229
Office Version
  1. 365
Platform
  1. Windows
I am not sure if this is even possible but I found this code doing a search and thought I would try to modify it to suit my needs which currently does not work

VBA Code:
Function LastModified() As Date
    LastModified = Workbook("O:\1_All Customers\Current Complaints\ToyotaData.xlsx").BuiltinDocumentProperties("Last Save Time")
End Function

For reference what modified from the original formula I found on the internet, was where it stated "Workbook("Filepath") WAS simply "Activeworkbook" When I tried the function it errored out and highlighed "Workbook" so i am assuming that what i changed was not a correct form of syntax.

What should i change to have this function work correctly?

End goal: display the Date of another work book that my active workbook uses to pull data from.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
That sounds more on the nose of what i was wanting i tried it but i am getting a compile error. Should i be trying to treat this as a Sub instead of a function?
1656591300493.png
 
Upvote 0
You didn't actually apply the information provided to you in the link.

VBA Code:
Sub GetDateModified()
    Dim LastModDate As Date

    LastModDate = LastModified(filespec:="O:\1_All Customers\Current Complaints\ToyotaData.xlsx")
    MsgBox LastModDate
End Sub

Function LastModified(filespec)
    Dim fs, f
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFile(filespec)
    LastModified = f.DateLastModified
End Function
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
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