Excel 2010 VBA 创建日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6859711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Excel 2010 VBA creation date
提问by CoolStraw
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.
如何在 excel 2010 中使用 VBA 获取当前工作簿文件的创建日期?我浏览了 ThisWorkBook 的所有属性,但似乎没有找到。
回答by Jacob
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 Docfor Office 2010, there is a list with other available properties on there, too.
这适用于 Excel 2003,没有 2010 来测试它。链接到Office 2010 的MSDN Doc,那里也有一个包含其他可用属性的列表。
回答by Paul Creasey
Use Scripting.FileSystemObject
Dim oFS As Object
Dim creationDate As String
Set oFS = CreateObject("Scripting.FileSystemObject")
creationDate = oFS.GetFile(ThisWorkbook.FullName).DateCreated
回答by Prashant Bhate
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
回答by dspies
I found that FileDateTime works best.
我发现 FileDateTime 效果最好。
FileDateTime (application.activeworkbook.path)
Tech on the netsays it applies to Excel 2016, 2013, 2011 for Mac, 2010, 2007, 2003, XP, and 2000
网上的技术说它适用于 Excel 2016、2013、2011 for Mac、2010、2007、2003、XP 和 2000