PDA

View Full Version : Last saved issue



nikki333
07-27-2017, 12:48 PM
Dear All,

I'm a total beginner and would be glad to get some help about retrieving document properties.

It seems no problem to retrieve the built in properties for the currently opened file (like shown below), but i want to get this info from another file.

Function UDatum()
Application.Volatile
UDatum = ActiveWorkbook.BuiltinDocumentProperties("Last save time")
End Function

So, I thought, I'd replace the ActiveWorkbook. part with the file location like so:

Workbooks("C:\workbook_***.xlsm").BuiltinDocumentProperties("Last Author")

That file should not be opened, just the properties should be read. Any help?

offthelip
07-27-2017, 04:10 PM
This routine will give you the last modified time using filescripting object. you will need to set a reference to Microsoft File Scripting Runtime in the VBA references:
obviously you can set the spath to any path, I just used the workbook path for testing



Sub getdatelm()
Dim FSO As New FileSystemObject
Dim myFolder As Folder

Dim myFile As File
spath = ActiveWorkbook.Path

Set myFolder = FSO.GetFolder(spath)


For Each myFile In myFolder.Files
Name = myFile.Name
datelm = myFile.DateLastModified
MsgBox (Name & " " & datelm)
Next


End Sub