Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find all the files in a folder
I had been using the FileSearch function to locate all the files of a
particular type in a folder. Office2007 appears to have replaced that function with a FileSystemObject class, but i can't get that to work. Here is what I had been using. Any help would be appreciated. Set fs = Application.FileSearch With fs .LookIn = Range("C7").Value .SearchSubFolders = True .FileName = "*.csv" If .Execute() 0 Then Row = 1 For i = 1 To .FoundFiles.Count |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find all the files in a folder
Hi Phil
This works in 2007 although it is not clear from your code post what you want to do. Looks like you are counting the files found so that is what the following does. Post if you want a more specific reply. Take care Marcus Option Explicit Sub Open_Txt() Dim oWbk As Workbook Dim wb As Workbook Dim sFil As String Dim sPath As String Dim strFullName As String Dim Cnt As Integer Dim i As Integer Application.DisplayAlerts = False Application.ScreenUpdating = False Cnt = 0 sPath = "R:\" ChDir sPath sFil = Dir("*.csv") Do While sFil < "" strFullName = sPath & sFil sFil = Dir Cnt = Cnt + 1 Loop MsgBox Cnt End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to find all folder and/or files in a specific location | Excel Programming | |||
How to find all folder and/or files in a specific location | Excel Discussion (Misc queries) | |||
find all the excel files in a folder. | Excel Programming | |||
Find and Replace on all worksheets on all files in a folder | Excel Programming | |||
how to step thru only one subfolder of a folder to find like files | Excel Programming |