Inserting date from File properties

musicmstr

New Member
Joined
Jun 24, 2023
Messages
3
Office Version
  1. 2013
Platform
  1. Windows
hi all and thanks for any help in advance,

so i have been trying to insert the date of the file created into an excel spreadsheet based on when the file was created, the problem being is its picking up the original file creation date, so i originally created the file on the 19/06/2023 and i used the save as function to create a copy of that file on the 26/06/2023, the problem being is when you right click on the file and click properties it tells you the date and time the file was created. the correct date and time, but when i use VBA to create a macro it refers to the original file not the new file.

i have used the following and its giving me the incorect dates

Sub Workbook_Open()
Range("I1").Value = Format(ThisWorkbook.BuiltinDocumentProperties("Creation Date"), "short date")
Range("I2").Value = Format(ThisWorkbook.BuiltinDocumentProperties("Last Save Time"), "short date")
End Sub

i have also tried multiple weekday and date mixes to try and get the correct date with no correct equation

hoping someone can help as im at a loss

thanks
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Maybe
VBA Code:
Range("I1").Value = Format(CreateObject("Scripting.FileSystemObject").GetFile(ThisWorkbook.FullName).DateCreated, "short date")
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,659
Members
449,114
Latest member
aides

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