How do I display all the filename in a folder in excel ?
How do I display all the filename in a folder in excel ?
Example : In c:\abc folder got filename file1.txt , file2.txt and file3.txt How do I display in excel in the following order :- c:\abc\file1.txt c:\abc\file2.txt c:\abc\file3.txt Regards, Tee |
How do I display all the filename in a folder in excel ?
Sub ListAllFilesInFolder() 'Jim Cone - Portland Oregon - USA Dim strPath As String Dim oFSO As Object Dim oFile As Object Dim oFolder As Object Dim N As Long strPath = "C:\Program Files\Microsoft Office\Office11" N = 1 Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFolder = oFSO.GetFolder(strPath) Cells(N, 1).Value = oFolder.Path N = N + 1 For Each oFile In oFolder.Files Cells(N, 2).Value = oFile.Name N = N + 1 Next 'oFile Set oFSO = Nothing Set oFile = Nothing Set oFolder = Nothing End Sub -- Jim Cone Portland, Oregon USA http://www.realezsites.com/bus/primitivesoftware (Excel Add-ins - free trial of "List Files" - no registration) "Eng Teng" wrote in message How do I display all the filename in a folder in excel ? Example : In c:\abc folder got filename file1.txt , file2.txt and file3.txt How do I display in excel in the following order :- c:\abc\file1.txt c:\abc\file2.txt c:\abc\file3.txt Regards, Tee |
All times are GMT +1. The time now is 09:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com