Make a file list using Excel

Glen Charles Rowel

New Member
Joined
Oct 11, 2004
Messages
44
What formula can I paste into Excel to have all the files in a folder (eg c:\in here) listed. Most of the files are TXT and HTML.

Thanks

Regards,

Glen Charles Rowell
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Glen

Whatever you posted hasn't appeared I'm afraid?
 
Upvote 0
BTW I'm making an index for a JavaScript dictionary. That's why I'm trying to find out how to do this. Typing in 108,000 lines like this would take a long time. :wink:
 
Upvote 0
Glen

I'm still a little unsure exactly what you're looking for but is it something along these lines:
Code:
Sub ListTxtAndHTML()
Dim I As Long
Dim strFileName As String
Dim strFriendlyName As String

    ActiveSheet.Range("A1:B1") = Array("Text", "HTML")
    
    With Application.FileSearch
        .NewSearch
        .LookIn = "C:\Papers\"
        .Filename = "*.txt*"
        .Execute
        
        For I = 1 To .FoundFiles.Count
        
            strFileName = Mid(.FoundFiles(I), InStrRev(.FoundFiles(I), "\") + 1)
            strFriendlyName = Left(strFileName, InStrRev(strFileName, ".") - 1)
            
            ActiveSheet.Range("A" & (I + 1)) = "<option VALUE=" & Chr(34) & "../" & strFileName & Chr(34) & ">" & strFriendlyName & "</option>"

        Next
    End With

    With Application.FileSearch
        .NewSearch
        .LookIn = "C:\Papers\"
        .Filename = "*.htm*"
        .Execute
        
        For I = 1 To .FoundFiles.Count
        
            strFileName = Mid(.FoundFiles(I), InStrRev(.FoundFiles(I), "\") + 1)
            strFriendlyName = Left(strFileName, InStrRev(strFileName, ".") - 1)
            
            ActiveSheet.Range("B" & (I + 1)) = "<option VALUE=" & Chr(34) & "../" & strFileName & Chr(34) & ">" & strFriendlyName & "</option>"
        Next
    End With
End Sub
 
Upvote 0
That worked perfectly (y) and with these examples I should be able to easily change anything that doesn't work. Thank you sooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo much.

Glen Charles Rowell
 
Upvote 0
Need help

Hi there

I've been looking at this script and it is very helpful. The thing I need is a modified version of this.

I want to create an index of all files and all subfolders in a specific folder.

For example. In column A would be a number (that goes up)
In column B would be the full path to the file name
In column C would be the folder name that the file is in
In column D would be the file name
In column E would be the file type

I also want to make all folder names "linkable" - meaning that when I click on that file name - it will open up that file (Like the Ctrl-K link file thing)

ALSO - to make things more complicated.. I need to have the links to the file name dynamic.... so if I move this index somewhere else with all the files.... the links will still work (This part is not necessary though - because I could just run the script again)

PLEASE help

Thank you!
 
Upvote 0
spammy

I suggest you create a new post with your specific question.

You could put a likn back to this thread for reference.
 
Upvote 0

Forum statistics

Threads
1,215,945
Messages
6,127,840
Members
449,411
Latest member
adunn_23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top