How do I can I read a directory from CD and place it in excel

  • Thread starter Thread starter Jaggie
  • Start date Start date
J

Jaggie

I want to archive my CD-roms and find the back in a excel spreadsheet. Does
anyone know how to read directory structure from disk and import them into
axcel?
 
Jaggie,

Assuming your CD drive is D, this will list all files on the active sheet.

Sub FindCDFiles()
With Application.FileSearch
.NewSearch
.LookIn = "D:\"
.SearchSubFolders = True
.FileType = msoFileTypeAllFiles
If .Execute(msoSortOrderDescending) > 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
Cells(i, 1).Value = .FoundFiles(i)
Cells(i, 2).Value = FileDateTime(.FoundFiles(i))
Cells(i, 3).Value = FileLen(.FoundFiles(i))
Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub

HTH,
Bernie
MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top