Wednesday, August 7, 2013

Listing of File Names with Different Folders



Public pathname As String
Public fileformat As String
Dim strfile As String
Dim rowcount As Long
'Parameters are passed from Forms
Sub ListFiles()

rowcount = 2
strfile = Dir(pathname & "\" & fileformat, vbNormal)
    If Len(strfile) = 0 Then
            MsgBox "No file Exists", vbOKOnly

    End If
    Application.ScreenUpdating = False
    Do While Len(strfile) > 0
 
        Cells(rowcount, 3) = strfile
        Cells(rowcount, 4) = FileDateTime(pathname & "\" & strfile)
        rowcount = rowcount + 1
        'get nextfile from Folder
        strfile = Dir
    Loop
    Columns.AutoFit
End Sub

No comments:

Post a Comment