LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
temporary directory files IMJQT Excel Discussion (Misc queries) 1 April 9th 08 12:30 AM
Files in a directory? Greg B Excel Discussion (Misc queries) 5 May 11th 05 09:46 PM
Load all files in a directory Greg B... Excel Discussion (Misc queries) 2 March 2nd 05 12:22 PM
Check if directory empty OR no of files in directory. Michael Beckinsale Excel Programming 2 December 4th 03 10:12 PM
Open files in directory V. Roe Excel Programming 2 November 4th 03 07:45 PM


All times are GMT +1. The time now is 04:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"