Date create problem

kato01

Board Regular
Joined
Sep 9, 2005
Messages
81
Hello

I am using the function. the f.DateCreated gives me the today value, not the real the file created date.
Any ideas?
Thanks


VBA Code:
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
Sheets("MAIN").Select
filespec = Sheets("MAIN").Cells(1, 3).Value
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(filespec)
Sheets("MAIN").Cells(2, 5).Value = f.DateCreated
Sheets("MAIN").Cells(3, 5).Value = f.DateLastAccessed
Sheets("MAIN").Cells(4, 5).Value = f.DateLastModified
End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hello, this VBA basics event demonstration well works on my side :​
VBA Code:
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
    If Success Then
        Debug.Print FileDateTime(FullName)
    End If
End Sub
 
Upvote 0
According to your initial code, removing the useless, another VBA event demonstration working as expected on my side :​
VBA Code:
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
With CreateObject("Scripting.FileSystemObject").GetFile(FullName)
Debug.Print .DateCreated
Debug.Print .DateLastModified
End With
End Sub
 
Upvote 0
Debug.Print FileDateTime(FullName)
Debug.Print .DateCreated
Debug.Print .DateLastModified

give all the same date and time.

Unless I am missing something this can't be right
The file is old and the DateCreated should be different from DateLastModified

also, in
FileDateTime function (Visual Basic for Applications)
it says
"FileDateTime function - Returns a Variant (Date) that indicates the date and time when a file was created or last modified."

How one would know what the value of the function is? created or modified

Thanks
 
Upvote 0
give all the same date and time.
So weird as work as expected on my side so the devil is on yours …​
After closing Excel, open Windows Explorer and check the dates, then retry … Maybe reboot the computer …​
 
Upvote 0

Forum statistics

Threads
1,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top