Below the code allows me to get the last modified, but I want to get the last time the file was access. How do get the "Last Accessed" Date/Time?
If CurrentTime < ActiveWorkbook.BuiltinDocumentProperties("Last Save Time") Then
MsgBox "Date Moved"
Below the code allows me to get the last modified, but I want to get the last time the file was access. How do get the "Last Accessed" Date/Time?
If CurrentTime < ActiveWorkbook.BuiltinDocumentProperties("Last Save Time") Then
MsgBox "Date Moved"
You would have to save that last accessed time somewhere and retrieve that, or you could use FSO on the disk file.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Ok. I would assume I would have to place this in a cell. If so, how do I achieve that?Originally Posted by xld
Also, the FSO seems viable as well. How about it?
[vba]
Dim fso As Object
Set fso = CreateObject("Scripting.FilesystemObject")
MsgBox fso.getfile("C:\test\Bob test.xls").datelastaccessed
Set fso = Nothing
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Thanks again. Only problem I see I will run into, if the file is changed/moved to a different location, it would cause an error. is there any other way to achieve this?Originally Posted by xld
You could add it to a Range Name, but the Save may be an issue.
[VBA]
Private Sub Workbook_Open()
With ActiveWorkbook
On Error Resume Next
.Names("LastAccess").Delete
.Names.Add Name:="LastAccess", RefersToR1C1:="=""" & Format(Now(), "DD/MM/YY hh:mm:ss") & """"
.Save
End With
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
If the file is moved, you code will have problems with it whatever, not just this bit.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
This is cross-posted and closed here.
Thanks Norie
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'