[英]How to check timestamp of a text file using VBA
我正在尝试在Excel 2003 VBA(Windows XP)中编写代码,以确定外部TXT文件是否具有不同的时间戳,因此如果更改,我可以“导入”它。
VBA中有什么功能可以救我吗?
我想你想要修改日期。 如果是,那么看看这个
Debug.Print FileDateTime("C:\Sample.txt")
显示的日期和时间格式基于系统的区域设置。
编辑
使用FileSystemObject
Option Explicit
Sub Sample()
Dim oFS As Object
Dim sFile As String
sFile = "C:\MyFile.txt"
Set oFS = CreateObject("Scripting.FileSystemObject")
'~~> Created Date
Debug.Print "Created Date : "; oFS.GetFile(sFile).DateCreated
'~~> Modified Date
Debug.Print "Modified Date : "; oFS.GetFile(sFile).Datelastmodified
Set oFS = Nothing
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.