简体   繁体   中英

Check last saved date on all CSV files in a folder

Pretty simple question really, I suppose. How can I amend the below so that rather than looking at LOI.CSV it looks at all .CSV files in the Intraday Folder?

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

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

Try this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM