Results 1 to 5 of 5

Thread: [RESOLVED] Excel VBA - Show Last Saved/Modified Date

  1. #1
    Super Moderator Hack's Avatar
    Join Date
    Aug 01
    Location
    Searching for mendhak
    Posts
    58,283

    Resolved [RESOLVED] Excel VBA - Show Last Saved/Modified Date

    I need to display the date and time a spreadsheet was last saved each time the sheet is opened. I use the following function and incorporate it as shown
    Code:
    Public Function myDate()
      myDate = Format(FileDateTime(Application.ActiveWorkbook.FullName), "mm/dd/yyyy h:n ampm")
    End Function
    
    Private Sub Workbook_Open()
    Sheet1.Range("D38") = myDate
    End Sub
    The problem is that when the file is opened is displayes the current date and time not the last time the file was saved.

    How would I fix this?

    I've done a fair amount of Googling about as well as looking through the Excel VBA code here on VBF and the general consensus seems to be that using FileDateTime is the way to go....but it doesn't want to play the way Uncle Hack needs it to play.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  2. #2
    Fanatic Member BillBoeBaggins's Avatar
    Join Date
    Jan 03
    Location
    in your database, dropping your tables.
    Posts
    628

    Re: Excel VBA - Show Last Saved/Modified Date

    Code:
    ?excel.Application.ThisWorkbook.BuiltinDocumentProperties.count
     30 
    ?excel.Application.ThisWorkbook.BuiltinDocumentProperties("Last Author")
    Sutter Connect
    ?excel.Application.ThisWorkbook.BuiltinDocumentProperties("Creation Date")
    10/14/1996 4:33:28 PM 
    ?excel.Application.ThisWorkbook.BuiltinDocumentProperties("Last Save Time")
    11/29/2005 1:10:27 PM
    http://msdn.microsoft.com/en-us/libr...es(VS.80).aspx

  3. #3
    Super Moderator Hack's Avatar
    Join Date
    Aug 01
    Location
    Searching for mendhak
    Posts
    58,283

    Re: Excel VBA - Show Last Saved/Modified Date

    BuiltinDocumentProperties -

    Didn't see that comin'

    Thank you sir!
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  4. #4
    Fanatic Member BillBoeBaggins's Avatar
    Join Date
    Jan 03
    Location
    in your database, dropping your tables.
    Posts
    628

    Re: [RESOLVED] Excel VBA - Show Last Saved/Modified Date

    I was thinking there HAS to be something in the Excel Properties with this so I just started cycling through the properties and hit gold with BuiltInDocumentProperties. heh.

  5. #5
    New Member
    Join Date
    Aug 12
    Location
    Gold Coast, Australia
    Posts
    1

    Re: Excel VBA - Show Last Saved/Modified Date

    Hi 'Hack'. Can you show me how BillBooe's code fits into your suggested code, assuming that it does. As you probably can tell, I am a bit of a novice with VB and coding. Like you, I want the last saved date to remain 'intact' upon next opening.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •