Avatar of rrhandle8
rrhandle8
Flag for United States of America asked on

Find creation date of Excel Workbook

I am opening Excel workbooks use VBA in Access.  I want to get the original creation date of the workbook, but what I am getting is the date is was moved to the current folder.


Dim WkBk As Excel.Workbook
Set WkBk = ExcelApp.Workbooks.Open(filename:=WbkPathName)
WkBk.BuiltinDocumentProperties("Creation Date")

Open in new window



I tried using this, but it causes an error:

WkBk.BuiltinDocumentProperties.items("Creation Date").Value

Open in new window



Access 2003
Excel 2010
Microsoft ExcelMicrosoft Access

Avatar of undefined
Last Comment
Farzad Akbarnejad

8/22/2022 - Mon
Flyster

If it's the active workbook, try this:

ActiveWorkbook.BuiltinDocumentProperties("Creation Date")

Flyster
rrhandle8

ASKER
ActiveWorkbook.BuiltinDocumentProperties("Creation Date") also returns today's date.  Today is the day I saved it to my computer.
The original creation date is back in August, and can be seen on the Statistics tab of the property box.
rrhandle8

ASKER
CORRECTION -- The date on the Statistics tab is today's date.  The date on the general tab is back in August.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Farzad Akbarnejad

rrhandle8

ASKER
I already tried that.  Didn't work.
I have discovered the only way to get the original creation date is to use the FileSystemObject.

Option Compare Database
Option Explicit
Function getCreationDate(strCompleteFilePath As String) As Date
    Dim objFileSystem       As Object
    Dim objFile             As Object
    Set objFileSystem = CreateObject("Scripting.FileSystemObject")
    If objFileSystem.FileExists(strCompleteFilePath) Then
        Set objFile = objFileSystem.GetFile(strCompleteFilePath)
        getCreationDate = objFile.DateCreated
    Else
        MsgBox "The specified file '" & strCompleteFilePath & "' does not exist.",    vbInformation, "Creation Date"
    End If
    Set objFile = Nothing
 End Function
 Function getOpnWbkCreationDate(wbkOpened As Workbook) As Date
     getOpnWbkCreationDate = wbkOpened.BuiltinDocumentProperties("Creation Date")
 End Function
 Sub ExecuteFunc()
     MsgBox getCreationDate(ThisWorkbook.FullName)
    MsgBox getOpnWbkCreationDate(ThisWorkbook)
End Sub

Open in new window

rrhandle8

ASKER
I correct myself again.  Even using the FSO, sometimes the original creation day is captured, other times it is not.  Very confusing.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Farzad Akbarnejad

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
rrhandle8

ASKER
There was no answer to this problem.
Farzad Akbarnejad

rrhandle8,
If you don't get your proper solution you can request for attention to this question and get points refund.

-FA