I'm trying to amend the Created Date of a list of files using excel and vba.
I've worked out how to amend the modified date using the below data, but I'm unable to get it to work on the DateCreated.
Sub update_file_dates()
Dim oFSO As Object
Dim oShell As Object
Dim oFile As Object
Dim oFolder As Object
Dim sFile As String
Dim rw, erw As Integer
rw = 2
erw = sh01.Cells(sh01.Rows.Count, 1).End(xlUp).Row
Do Until rw > erw
sFile = sh01.Cells(rw, 2) & "\" & sh01.Cells(rw, 1)
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Shell.Application")
Set oFile = oFSO.GetFile(sFile)
Set oFolder = oShell.Namespace(oFile.ParentFolder.Path)
oFolder.Items.Item(oFile.Name).ModifyDate = DateSerial(2000, 1, 12) + TimeSerial(5, 35, 17)
Set oFolder = Nothing
Set oFile = Nothing
Set oShell = Nothing
Set oFSO = Nothing
rw = rw + 1
Loop
End Sub
Thank you
You will need to use the Windows API for this task. I took the liberty of updating the code you provided, using code I pulled from my library:
Here is the referenced code:
and the Windows API code: