Solved

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

Posted on 2014-02-18
4
1,204 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

778 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