View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Stuart[_3_] Stuart[_3_] is offline
external usenet poster
 
Posts: 50
Default External File Paths

Bob,

Thank you for your repsonse.....greatly appreciated.

It keeps debugging at the part of the code

this.Worksheets.Add.Name = "FileList"

Any ideas?

I attempted the folder C:\temp and it didnt work.

Thanks Bob,

Stuart

Bob Phillips wrote:
You might be able to do something with this code

Dim FSO As Object

Sub ProcessFiles()
Dim i As Long
Dim sFolder As String
Dim fldr As Object
Dim Folder As Object
Dim file As Object
Dim Files As Object
Dim this As Workbook
Dim cnt As Long

Set FSO = CreateObject("Scripting.FileSystemObject")

Set this = ActiveWorkbook
this.Worksheets.Add.Name = "FileList"
sFolder = "C:\MyTest" '<=== change to suit
If sFolder < "" Then
Set Folder = FSO.GetFolder(sFolder)
Set Files = Folder.Files
cnt = 1
For Each file In Files
If file.Type = "Microsoft Excel Worksheet" Then
Worksheets("FileList").Cells(cnt, "A").Value = file.Path
cnt = cnt + 1
End If
Next file

End If ' sFolder < ""

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Stuart" wrote in message
oups.com...
Hi there,

Since my previous tests failed - the file paths werent entered into the
spreadsheet correctly!! I wondered if it were possible to have excel
extract a list of all the files in a drive and put each file found's
full path location in a row on the spreadsheet.

for example - I have my C Drive. I would expect excel to find all
Windows files and then list their full path down column A,

Hope this explains what I'm looking for,

Thanks in advance,

Kind Regards,

Stuart