Want Formula (if any)/code to take Folder list in Excel

  • Thread starter Thread starter maximus
  • Start date Start date
M

maximus

Hi,

Need help

I want details(Name,Size,Path,last updated) of files containing in
folder as well as sub folder in one excel.

I know the Command prompt method where list is saved in notepad and we
need to copy the same in excel.

I am using Office 2003 & 2007.

Thanks you in anticipation
Tejas
 
Hi,

Need help

I want details(Name,Size,Path,last updated) of files containing in
folder as well as sub folder in one excel.

I know the Command prompt method where list is saved in notepad and we
need to copy the same in excel.

I am using Office 2003 & 2007.

Thanks you in anticipation
Tejas

Hi Tejas,
have a look at http://www.mrexcel.com/archive/VBA/4388.html and do a
google search with the keywords "excel dirlist"
Hope that helps
Cheers Michael
 
I use this code to create a path & name list directly into a worksheet.
(You should be able to add Size & last updated).

I hope this helps?
Charlie (from Australia)

<<< Copy the code below into a new Module >>>>>>

Option Explicit
Dim FileListToProcess(200) As String

Sub Build_List()
Dim WkMain As Workbook
Dim ShMain As Worksheet
Dim s As Worksheet
Dim CurFilePath As String
Dim NumberOfFilesSelected As Integer
Set WkMain = ActiveWorkbook
Set ShMain = WkMain.ActiveSheet
Dim lngCount As Integer
'Get current file path
CurFilePath = GetCurrentFilePath
'Let user select the files to process
NumberOfFilesSelected = UseFileDialogOpen
'Check each selected file and exit if problem
For lngCount = 1 To NumberOfFilesSelected
If Not FileExists(FileListToProcess(lngCount - 1)) Then
MsgBox "Please select a valid file name" & " File " &
FileListToProcess(lngCount - 1) & " Is Invalid"
Exit Sub
End If
Next lngCount
For lngCount = 1 To NumberOfFilesSelected
ActiveCell.FormulaR1C1 = (FileListToProcess(lngCount - 1))

ActiveCell.Range("a1").Offset(1, 0).Select

Next lngCount
ShMain.Activate
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

Function GetCurrentFilePath() As String
GetCurrentFilePath = Mid(Workbooks(1).FullName, 1,
(InStrRev(Workbooks(1).FullName, "\")))
End Function
Function UseFileDialogOpen() As Integer
Dim lngCount As Long
Dim FileNames
Dim icount As Integer
FileNames = Application.GetOpenFilename("All Files (*.*), *.xls", ,
"Please select the Files to List", , True)
For icount = 1 To UBound(FileNames)
FileListToProcess(icount - 1) = FileNames(icount)
Next icount
UseFileDialogOpen = UBound(FileNames)
End Function

Function FileExists(Path As String) As Integer
Dim X As Integer
X = FreeFile

On Error Resume Next
If Dir(Path$) <> "" Then
Open Path$ For Input As X
FileExists = True
Else
FileExists = False
End If
Close X
End Function
 
Back
Top