View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
ALEX ALEX is offline
external usenet poster
 
Posts: 493
Default listing directory files in a spreedsheet automatically

Hi Chijanzen had a complie error or maybe i did something wrong

"chijanzen" wrote:

alex:

try it,

Public Sub ListFilesToWorksheet()
On Error Resume Next
Dim stMedd As String
stMedd = "Please Select Folder:"
Set obMapp = CreateObject("Shell.Application").BrowseForFolder( 0,
stMedd, &H1)
If Not obMapp Is Nothing Then
Directory = obMapp.self.Path & "\"
Else
Exit Sub
End If
With Application.FileSearch
.NewSearch
.LookIn = Directory
.Filename = "*.xls"
.SearchSubFolders = True
.Execute
For i = 1 To .FoundFiles.Count
strFileName = Dir(.FoundFiles(i))
strPath = Left(.FoundFiles(i), Len(.FoundFiles(i)) -
Len(strFileName))
strExtension = ""
Cells(i, 1) = .FoundFiles(i)
ActiveSheet.Hyperlinks.Add anchor:=Cells(i, 1),
Address:=.FoundFiles(i)
r = r + 1
Next i
End With

End Sub

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"alex" wrote:

I have a file on my c drive that contain a lot of documents i need to find a
way to have these files listed in a colum on a spread sheet everytime a file
gets drop into a parent file automatically how can i accomplish this