![]() |
Working through files in a directory
Hi
Can anyone help me with the code to get a list of the files and folders in a given path i.e. c:\ and return them back to an excel sheet. TIA Nath |
Working through files in a directory
Nath,
One way Sub CreateFormsListBox() Dim FSO As Object Dim oFile As Object Dim oFiles As Object Dim oFolder As Object Dim i As Long Dim sPath As String Worksheets.Add.Name = "FileList" Set FSO = CreateObject("Scripting.FileSystemObject") sPath = "C:\MyTest" Set oFolder = FSO.GetFolder(sPath) Set oFiles = oFolder.Files For Each oFile In oFiles i = i + 1 ActiveSheet.Cells(i, "A").Value = oFile.Name Next oFile Range("A1").Select End Sub -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "nath" wrote in message ... Hi Can anyone help me with the code to get a list of the files and folders in a given path i.e. c:\ and return them back to an excel sheet. TIA Nath |
All times are GMT +1. The time now is 11:44 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com