Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Create a list of all files in a folder

I would like to create a list of all the files in a folder, but am
fumbling with the detail. The code below only lists the files with
extension ".doc" in the folder in question. There ore other types of
files (.pdf, .tiff) but they are not listed. Any reason why, and how
does one work around it.

Thanks
Laurence

Sub test2()
With Application.FileSearch
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Sheets("Sheet1").Range("A" & i).Value = .FoundFiles(i)
Next i
End With


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Create a list of all files in a folder

On Jan 26, 3:50*pm, lombardm wrote:
I would like to create alistofallthefilesin afolder, but am
fumbling with the detail. The code below only lists thefileswith
extension ".doc" in thefolderin question. There ore other types offiles(.pdf, .tiff) but they are not listed. Any reason why, and how
does one work around it.

Thanks
Laurence

Sub test2()
With Application.FileSearch
* * For i = 1 To .FoundFiles.Count
* * * * MsgBox .FoundFiles(i)
* * * Sheets("Sheet1").Range("A" & i).Value = .FoundFiles(i)
* * Next i
End With

End Sub


I think I must do some homework before requesting help. A quick search
of this group reveals several discussions on this topic, so I need to
follow that up first. Excuse the hasty post!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Create a list of all files in a folder

Probably cuz you didn't specify where to look. From HELP
With Application.FileSearch
.LookIn = "c:\my documents"
.FileType = msoFileTypeExcelWorkbooks
.Execute
End With
============
You may like this
Sub FindFiles()
Application.ScreenUpdating = False
Dim FN As String
Dim ThisRow As Long
Dim FileLocation As String
FileLocation = "c:\yourfoldernamehere\*.*"
FN = Dir(FileLocation)
Do Until FN = ""
ThisRow = ThisRow + 1
Cells(ThisRow, 1) = FN
FN = Dir
Loop
Application.ScreenUpdating = True
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"lombardm" wrote in message
...
I would like to create a list of all the files in a folder, but am
fumbling with the detail. The code below only lists the files with
extension ".doc" in the folder in question. There ore other types of
files (.pdf, .tiff) but they are not listed. Any reason why, and how
does one work around it.

Thanks
Laurence

Sub test2()
With Application.FileSearch
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Sheets("Sheet1").Range("A" & i).Value = .FoundFiles(i)
Next i
End With


End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to create a folder and copy files GainesvilleWes New Users to Excel 2 February 26th 07 06:33 PM
How to create a copy of a folder having five files in it, & rename Matthews Excel Worksheet Functions 1 November 7th 06 03:42 PM
List files in a folder gilgil Excel Programming 2 November 23rd 05 02:02 PM
create a list of worksheet names (from a single folder, or open files) Drew Excel Discussion (Misc queries) 2 April 15th 05 04:58 PM
How to get the list of files in a folder yang Excel Programming 1 October 16th 03 12:53 PM


All times are GMT +1. The time now is 12:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"