Excel 2010 VBA creation date

2019-02-17 12:18发布

问题:

How to get the current workbook file creation date using VBA in excel 2010? I browsed all the properties of ThisWorkBook I don't seem to find something there.

回答1:

MsgBox ActiveWorkbook.BuiltinDocumentProperties("Creation Date")
'Output: 25.07.2011 14:51:11 

This works for Excel 2003, don't have 2010 to test it. Link to MSDN Doc for Office 2010, there is a list with other available properties on there, too.



回答2:

Use Scripting.FileSystemObject

Dim oFS As Object
Dim creationDate As String

Set oFS = CreateObject("Scripting.FileSystemObject")
creationDate = oFS.GetFile(ThisWorkbook.FullName).DateCreated


回答3:

Use

ActiveWorkbook.BuiltinDocumentProperties.Item("Creation date").Value

To List all properties run this macro

Public Sub listProperties()
rw = 1
Worksheets(1).Activate
For Each p In ActiveWorkbook.BuiltinDocumentProperties
    Cells(rw, 1).Value = p.Name
    On Error Resume Next
    Cells(rw, 2).Value = p.Value
    rw = rw + 1
Next
End Sub


回答4:

I found that FileDateTime works best.

FileDateTime (application.activeworkbook.path)

Tech on the net says it applies to Excel 2016, 2013, 2011 for Mac, 2010, 2007, 2003, XP, and 2000

MSDN VBA 2010 - FileDateTime