Copying folder list to Excel spreadsheet

  • Thread starter Thread starter Peter Pardun
  • Start date Start date
Peter,

This code gets the FileNames, but doesn't store the names in the worksheet -
should be easy.
NOTE: - Hidden files aren't picked up.

Sub test()

Dim sFileName As String
Dim sMainDir As String

sMainDir = "C:\"

sFileName = Dir(sMainDir & "*.*") ' Initialize "Dir" command!
Do Until sFileName = ""

' Store name here

sFileName = Dir ' Get next file with "Dir"!
Loop

End Sub


regards,

JohnI
 
Hi Peter,
Using Start locate the Command Prompt program
Navigate to the folder of interest
Type: DIR > OUT>TXT
This is an old DOS (pre-Windows) trick to get a listing of a folder
('directory') sent to a file
Open the file in Excel
You will need to use Data|Text to Columns to separate names, size etc.

Bernard (showing his age)
 
Back
Top