-------------------------
Function iFileDate(iPh, n)
' 参数说明:
' iph 文件路径。
' n 时间类型。 1 为 创建时间;2 为 最后修改时间
If Dir(iPh) = "" Then Exit Function
Dim fs: Set fs = CreateObject("Scripting.FileSystemObject")
Dim f: Set f = fs.GetFile(iPh)
If n = 1 Then iFileDate = f.DateCreated
If n = 2 Then iFileDate = f.DateLastModified
End Function
---------------------

具体使用方法举例:
---------------
Sub iTest()
Dim iPh, iDate1, iDate2
iPh = "G:\D baiduHi\VBA 文件操作\a.xls"
If Dir(iPh) = "" Then
MsgBox "下面的文件不存在:" & vbCrLf & iPh, vbCritical
Exit Sub
End If
iDate1 = "  创建时间:" & vbTab & iFileDate(iPh, 1)
iDate2 = "最后修改时间:" & vbTab & iFileDate(iPh, 2)
MsgBox iPh & vbCrLf & iDate1 & vbCrLf & iDate2
End Sub

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 rick134 的頭像
    rick134

    rick134的部落格

    rick134 發表在 痞客邦 留言(0) 人氣()