[RESOLVED] Workbook/File Creation Date in Excel VBA
I am using a macro in Excel VBA which opens a text file as a workbook.
I need to get the Creation Date of the text file, not the Last Modified date.
So far I cannot find any way to get the creation date using the Workbooks object in VBA, and FileDateTime sometimes gives the Last Modified date. :confused:
Re: Workbook/File Creation Date in Excel VBA
Here is some junk I threw together ... it should be self explanatory. I hope it helps ...
Code:
Sub Macro1()
'You must install a refernce to library: Microsoft Scripting Runtime
Dim fso As New FileSystemObject
Dim aFile As File 'Handle for fso 'File' Object
Dim aPath As String
Dim aName As String
'Set up your filespec
aPath = "C:\Temp\"
aName = "JUNK.txt"
If fso.FileExists(aPath & aName) Then
Set aFile = fso.GetFile(aPath & aName) '<< Example of setting handle
MsgBox "The File exists " & aFile.DateCreated
End If
'Clean House
Set aFile = Nothing
End Sub
Re: Workbook/File Creation Date in Excel VBA
MsgBox ActiveWorkbook.BuiltinDocumentProperties("Creation Date")
Available choices:
Title
Subject
Author
Keywords
Comments
Template
Last Author
Revision Number
Application Name
Last Print Date
Creation Date
Last Save Time
Total Editing Time
Number of Pages
Number of Words
Number of Characters
Security
Category
Format
Manager
Company
Number of Bytes
Number of Lines
Number of Paragraphs
Number of Slides
Number of Notes
Number of Hidden Slides
Number of Multimedia Clips
Hyperlink Base
Number of Characters (with spaces)