Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
listing directory files in a spreedsheet automatically
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
listing directory files in a spreedsheet automatically
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Directory listing | Excel Discussion (Misc queries) | |||
Listing Directory Contents in Worksheet | Excel Discussion (Misc queries) | |||
Directory listing | Excel Discussion (Misc queries) | |||
Directory listing manipulation | Excel Programming | |||
Recursive directory listing | Excel Programming |