copy & paste

R

Ray A

I would like to copy all the file names from a folder in explorer into Excel.
Is this possible? I am using Window XP and Excel 2003
 
B

Bernie Deitrick

Ray,

Dim i As Integer
With Application.FileSearch
.NewSearch
.LookIn = "C:\Documents and Settings"
.FileType = msoFileTypeAllFiles
.SearchSubFolders = False
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Range("A" & i).Value = .FoundFiles(i)
Next i
End If
End With

HTH,
Bernie
MS Excel MVP
 
A

ALLM

This is good info but I am not a programmer. Is there an alternative way to
do this. If not in Exel something else maybe?

Al
 
B

Bryan Hessey

One method:

click Start, Run and type CMD (to run a DOS window)

type CD\MyFolder
using the path to your folder
something like CD\Documents and Settings\MyFiles

type DIR /-b /w >ListFiles.txt
to copy a list of filenames to a file


type Exit
to close this window

This file (ListFiles.txt) can be opened into Excel.

Hope this helps

--
 
Top