Solved

VB Excel 2013 Macro to determine the last time a file was saved

Posted on 2014-02-18
4
1,217 Views
Last Modified: 2014-02-24
I am looking for a macro that will determine the last time a file was saved.  In other words I a have a Workbook open and wish to have a macro run that will put the date and time that another workbook was last saved.  Also the user that saved it.
0
Comment
Question by:DavidH7470
  • 2
4 Comments
 
LVL 81

Expert Comment

by:byundt
ID: 39868422
You access this information through the workbook's BuiltInDocumentProperties collection:
Sub LastSave()
Dim wb As Workbook
Set wb = ActiveWorkbook
MsgBox wb.BuiltinDocumentProperties("Last save time") & vbLf & _
        wb.BuiltinDocumentProperties("Last Author")
End Sub

Open in new window

0
 
LVL 81

Expert Comment

by:byundt
ID: 39868436
I can never remember the names of the document properties, and so write code to list them out each time.
Sub ListDocumentProperties()
Dim pp As DocumentProperty
On Error Resume Next
For Each pp In ActiveWorkbook.BuiltinDocumentProperties
    Debug.Print pp.Name & " " & pp.Value
Next
For Each pp In ActiveWorkbook.CustomDocumentProperties
    Debug.Print pp.Name & " " & pp.Value
Next
End Sub

Open in new window

0
 
LVL 8

Expert Comment

by:TheNautican
ID: 39868437
0
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 500 total points
ID: 39880623
Hi,

In case I am the only "Expert" to notice you actually asked for "...the date and time that another workbook was last saved...", please substitute the fully-qualified (folder &) filename for "c:\folder\Filename.xls" within the code below (that displays a Message Box with the last modified date of the specified file):

MsgBox CreateObject("Scripting.FileSystemObject").GetFile("c:\folder\Filename.xls").DateLastModified

Open in new window


You also asked for
...the user that saved it.
.

Assuming the other workbook is closed when the information is required, you will need to open the other workbook, execute code similar to that already provided above to retrieve the last author of the workbook (if the personal information has not been removed at the point of the latest modification), & then the other workbook closed (again).

Is that feasible for your requirements?

BFN,

fp.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
My experience with Windows 10 over a one year period and suggestions for smooth operation
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question