How can I use the DateLastModified property in VBA to pull into my current open spreadsheet, the last modified date of another file is one that is closed. I want, if possible, to add it to a cell. As always, your help is greatly appreciated.
How can I use the DateLastModified property in VBA to pull into my current open spreadsheet, the last modified date of another file is one that is closed. I want, if possible, to add it to a cell. As always, your help is greatly appreciated.
There is a small code which I am providing you below. Look at the same and then check it. Gives the date/time last saved to it:
Code:Function lastsaved() As Double lastsaved = ActiveWorkbook.BuiltinDocumentProperties(12) End Function
Run the first macro to get second macro to return the date.
Code:Sub anotherfiledate() ShowFileAccessInfo ("closedfile.xls") End Sub Sub ShowFileAccessInfo(filespec) Dim fs, f, s Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.GetFile(filespec) s = UCase(filespec) ' & vbCrLf Range("K3").Value = s & " Last Modified: " & f.DateLastModified End Sub
I have never tried entering VBA code before, I have always used Excel's inherent formulas to complete needed tasks, so I may need some further instruction if you wouldn't mind. I too need to list the modified date of another file that is located on a seperate drive. I pasted your code into module 1:
Sub anotherfiledate()
ShowFileAccessInfo ("Interventional.xlsx")
End Sub
Sub ShowFileAccessInfo(filespec)
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(filespec)
s = UCase(filespec) ' & vbCrLf
Range("K3").Value = s & " Last Modified: " & f.DateLastModified
End Sub
and changed the "closedfile.xls" to the document I am looking for. Do I need to list the whole path name ("H:\EXAMPLE FOLDER\Interventional.xlsx")?
Also, how do I get the code to display the other documents modified date in a specific cell (B1) within my active workbook? Thank you so much!
-T
Bookmarks