listing directory files in a spreedsheet automatically

G

Guest

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
 
G

Guest

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
 

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

Top