5

如何在 excel 2010 中使用 VBA 获取当前工作簿文件的创建日期?我浏览了 ThisWorkBook 的所有属性,但似乎没有找到任何东西。

4

4 回答 4

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

这适用于 Excel 2003,没有 2010 来测试它。链接到Office 2010 的MSDN Doc,那里也有一个包含其他可用属性的列表。

于 2011-07-28T13:28:57.730 回答
4

使用Scripting.FileSystemObject

Dim oFS As Object
Dim creationDate As String

Set oFS = CreateObject("Scripting.FileSystemObject")
creationDate = oFS.GetFile(ThisWorkbook.FullName).DateCreated
于 2011-07-28T13:29:59.650 回答
2

采用

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

要列出所有属性,请运行此宏

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
于 2011-07-28T13:44:11.013 回答
0

我发现 FileDateTime 效果最好。

FileDateTime (application.activeworkbook.path)

Tech on the net说它适用于 Excel 2016、2013、2011 for Mac、2010、2007、2003、XP 和 2000

MSDN VBA 2010 - 文件日期时间

于 2018-06-14T17:57:40.010 回答