检查文件夹中所有CSV文件的上次保存日期

时间:2012-07-13 12:48:31

标签: excel vba csv excel-vba last-modified

我认为非常简单的问题。如何修改下面的内容,以便查看LOI.CSV而不是查看日内文件夹中的所有.CSV文件?

LastSaved = FileDateTime("W:\Settlements\Intraday\LOT.csv")

If LastSaved < Date Then
  MsgBox ("The current day file for LOI was last saved " & LastSaved)
End If

1 个答案:

答案 0 :(得分:3)

试试这个

Const sPath As String = "W:\Settlements\Intraday\"

Sub LoopThroughFilesInAFolder()
    Dim StrFile As String

    StrFile = Dir(sPath & "\*.Csv")

    Do While Len(StrFile) > 0
        Debug.Print FileDateTime(sPath & "\" & StrFile)
        '~~> Rest of the code here
        StrFile = Dir
    Loop
End Sub