简体   繁体   中英

Excel 2010 VBA creation date

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.

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.

Use Scripting.FileSystemObject

Dim oFS As Object
Dim creationDate As String

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM