Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, I have tryed this code listed below and it work, but as you see it only
list files in folder spesifyed in: .LookIn = ... what I want to do is to find files from a dialogbox. Any of you who can tell me how????? -------------------------------------------------------------- Function CreateFileList(FileFilter As String, _ IncludeSubFolder As Boolean) As Variant ' returns the full filename for files matching ' the filter criteria in the current folder Dim FileList() As String, FileCount As Long CreateFileList = "" Erase FileList If FileFilter = "" Then FileFilter = "*.*" ' all files With Application.FileSearch .NewSearch .LookIn = "C:\My Documents" .Filename = FileFilter .SearchSubFolders = IncludeSubFolder .FileType = msoFileTypeAllFiles If .Execute(SortBy:=msoSortByFileName, _ SortOrder:=msoSortOrderAscending) = 0 Then Exit Function ReDim FileList(.FoundFiles.Count) For FileCount = 1 To .FoundFiles.Count FileList(FileCount) = .FoundFiles(FileCount) Next FileCount .FileType = msoFileTypeExcelWorkbooks ' reset filetypes End With CreateFileList = FileList Erase FileList End Function Sub TestCreateFileList() Dim FileNamesList As Variant, i As Integer 'ChDir "C:\Levende" ' activate the desired startfolder for the filesearch FileNamesList = CreateFileList("*.*", False) ' performs the filesearch, includes any subfolders ' present the result Range("A:A").ClearContents For i = 1 To UBound(FileNamesList) Cells(i + 4, 3).Formula = FileNamesList(i) Next i End Sub ----------------------------------------------------------------------------- |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
List Filenames from Folder | Excel Programming | |||
List all filenames & tab names | Excel Worksheet Functions | |||
Getting a list of filenames | Excel Programming | |||
Getting a list of filenames | Excel Programming | |||
List out FileNames.xls with K4 Blank | Excel Programming |