UDF Help.

  • Thread starter Thread starter Yppes
  • Start date Start date
Y

Yppes

Please help a newbie.

Could anyone, kindly, show me how I can program a UDF to
make a content of a cell, return "the last time the spread
sheet was saved". This cell in question is part of the
same spread sheet.

I'm running Excel 97.

The save function can be (both) when the file is still open
or right before it's closed. The content of a cell should
reflect (in date format) when the sheet is saved.

Thanks in advance.

Yppes
 
Yppes,

This function does the trick:

Function getLastSaved()
Dim FSO
Dim f
Set FSO = CreateObject("Scripting.FileSystemObject")
Set f = FSO.GetFile(ActiveWorkbook.FullName)
getLastSaved = f.DateLastModified
Set FSO = Nothing
Set f = Nothing
End Function

This returns a string in date/time format, such as "7/24/2004 5:05:32 PM".
You can take it from there.

Stan Scott
New York City
 
Function LastSaved()
LastSaved = ActiveWorkbook. _
BuiltinDocumentProperties("Last Save Time")
End Function

make sure that you format the target cell.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Just some additional information:
re: using built in document properties
Excel 97 doesn't maintain the builtin document propert Last Save Time

re: using FSO to look at file properties
When a file is opened, its DateLastModified is set to the time it was
opened. If you subsequently save it in that session, then that function
might work.
 

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

Back
Top