View Full Version : Solved: Detecting Last Time File Was Opened
How would I access the file attributes for the active workbook in order to test whether the workbook has already been opened earlier during the same day?
mancubus
09-28-2012, 01:17 PM
check this out:
http://www.vbaexpress.com/forum/showthread.php?t=18942
but not sure if it helps...
AirCooledNut
09-28-2012, 01:25 PM
Option Explicit
Sub GetLastSavedDTStamp()
Dim wWB As Workbook
Set wWB = ActiveWorkbook
On Error Resume Next
Debug.Print wWB.BuiltinDocumentProperties.Item(12).Value
On Error Goto 0
Set wWB = Nothing
End Sub
The reason for the On Error... is because if the Value doesn't exist (not all will) then the code will throw an error.
Highlight the BuiltinDocumentProperties word and hit the F1 key in the VB Editor to get further help on this.
check this out:
http://www.vbaexpress.com/forum/showthread.php?t=18942
but not sure if it helps...
Thanks. I'll check it out.
Option Explicit
Sub GetLastSavedDTStamp()
Dim wWB As Workbook
Set wWB = ActiveWorkbook
On Error Resume Next
Debug.Print wWB.BuiltinDocumentProperties.Item(12).Value
On Error Goto 0
Set wWB = Nothing
End Sub
The reason for the On Error... is because if the Value doesn't exist (not all will) then the code will throw an error.
Highlight the BuiltinDocumentProperties word and hit the F1 key in the VB Editor to get further help on this.
Thanks. I'll play round with code. I think I can figure out a way to adapt the code to work for my purposes.
several methods:
c011 = FileDateTime(ThisWorkbook.FullName)
c111 = ThisWorkbook.BuiltinDocumentProperties(12)
c111 = ThisWorkbook.BuiltinDocumentProperties("last save time")
c211 = CreateObject("scripting.filesystemobject").getfile(ThisWorkbook.FullName).datelastmodified
c311 = CreateObject("shell.application").namespace(ThisWorkbook.Path & "\").Items.Item(ThisWorkbook.Name).ModifyDate
With CreateObject("shell.application").namespace(ThisWorkbook.Path & "\")
c411 = .getdetailsof(.Items.Item(ThisWorkbook.Name), 3)
End With
several methods:
c011 = FileDateTime(ThisWorkbook.FullName)
c111 = ThisWorkbook.BuiltinDocumentProperties(12)
c111 = ThisWorkbook.BuiltinDocumentProperties("last save time")
c211 = CreateObject("scripting.filesystemobject").getfile(ThisWorkbook.FullName).datelastmodified
c311 = CreateObject("shell.application").namespace(ThisWorkbook.Path & "\").Items.Item(ThisWorkbook.Name).ModifyDate
With CreateObject("shell.application").namespace(ThisWorkbook.Path & "\")
c411 = .getdetailsof(.Items.Item(ThisWorkbook.Name), 3)
End With
Thanks for the additional insight.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.