File Directory info into Excel


When I use Windows File Directory, I can see the listings of a directory or sub directory showing such data as file name, file type and other file information.  How can I input that information into an Excel spreadsheet?



Honestly, I have no idea what you mean... edit your question and provide a more thorough explanation.
don (rep: 1247) Jan 10, '17 at 12:12 pm
Add to Discussion



Well here is a macro that you can use to navigate to a specific directory and then select it and list all files within it including their extensions.

Option Explicit
Sub GetFileNames()
Dim xRow As Long
Dim xDirect, xFname
Dim Dest As Range

'Change this to put the data in a different place in the workbook.
Set Dest = ActiveCell

With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Select a folder"
    If .SelectedItems.Count <> 0 Then
        xDirect = .SelectedItems(1) & "\"
        xFname = Dir(xDirect, 7)
        Do While xFname <> ""
            Dest.Offset(xRow) = xFname
            xRow = xRow + 1
            xFname = Dir
    End If
End With

End Sub

Answer the Question

You must create an account to use the forum. Create an Account or Login