Creation Date vs. Copy Date of a File

masahi007

New Member
Joined
Sep 1, 2022
Messages
4
Office Version
  1. 2021
Platform
  1. Windows
Hi all,
I want to know the Creation Date of a File (statical creation date) and NOT the date it was copy to my computer (general creation date). If I use this code, I obtein then copy date ... How can I know the Creation one?

thanks

Dim fSo As Object

Dim MyFile as string

Dim MyDate as date

MyFile = "c:\ThisFile.pdf"
Set fSo = CreateObject("Scripting.FileSystemObject")
MyDate = fSo.getfile(MyFile).datecreated
MsgBox "Creation Date: " & MyDate
Set fSo = Nothing
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
The only source of information available to you is the file's properties, and this statement

VBA Code:
MyDate = fSo.getfile(MyFile).DateCreated

Will provide the creation date stored in the file's properties.
 
Upvote 0
Thanks for the reply.
The problem is that I am getting the date the file was copied last time (5/6/2022) and not the original date the file was created (5/6/2020).
Any solution?
 
Upvote 0
I don't suppose it is just one file so that you don't need VBA ?
You have a chance of getting what you want from an Excel file using the built in properties ThisWorkbook.BuiltinDocumentProperties("Creation Date").

Unfortunately you seem to be looking at a pdf file and although I can see a similar field in the pdf file (File > Properties > Description) if I open it in Acrobat, I don't know if you can access it using VBA.
 
Upvote 0
Thanks for the reply.
The problem is that I am getting the date the file was copied last time (5/6/2022) and not the original date the file was created (5/6/2020).
Any solution?
The problem is that some file operations will change the stored date and at that point your options are limited. There are 3 dates that can be accessed:

  1. Creation date
  2. Last accessed date
  3. Last modified date

VBA Code:
MyDate = fSo.getfile(MyFile).DateCreated
MyDate = fSo.getfile(MyFile).DateLastAccessed
MyDate = fSo.getfile(MyFile).DateLastModified
 
Upvote 0
Indeed, my problem is when I want to get the dates of creation, modification and last access in any type of file (PDF for example).
Especially the creation date (which is not the same as the modification date).

Thanks
 
Upvote 0
Thank you both very much.
Indeed I have tried with the three dates and now I do get the result I want. I can't understand why it didn't work before.
All the best
 
Upvote 0

Forum statistics

Threads
1,214,639
Messages
6,120,679
Members
448,977
Latest member
dbonilla0331

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