Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default List Files in a Directory

I have gotten this code from a previous post (Thank You "KAAK", this
runs very fast) and modified it to work for my specific purpose. The
only thing I can't seem to get it to do is start its file listing in
the second row ("B2"). Thanks in advance

Sub ListFiles02()
'Using FileSearch to list the files in a directory
Dim i As Integer
i = 1
With Application.FileSearch
..NewSearch
..LookIn = "G:\06_Drawings\Drafting System\Standards\Blocks\Casework"
..Filename = "*.dwg"
.SearchSubFolders = True
'.SearchFolders = False
..Execute
For i = 1 To .FoundFiles.Count
Range("B" & i).Value = .FoundFiles(i)
Range("C" & i).Value = FileDateTime(.FoundFiles(i))
'Range("D" & i).Value = FileLen(.FoundFiles(i))
Next


End With


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default List Files in a Directory

Sub ListFiles02()
'Using FileSearch to list the files in a directory
Dim i As Integer
i = 1
With Application.FileSearch
..NewSearch
..LookIn = "G:\06_Drawings\Drafting System\Standards\Blocks\Casework"
..Filename = "*.dwg"
.SearchSubFolders = True
'.SearchFolders = False
..Execute
For i = 1 To .FoundFiles.Count
Range("B" & i + 1).Value = .FoundFiles(i)
Range("C" & i + 1).Value = FileDateTime(.FoundFiles(i))
'Range("D" & i + 1).Value = FileLen(.FoundFiles(i))
Next


End With


End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

wrote in message
oups.com...
I have gotten this code from a previous post (Thank You "KAAK", this
runs very fast) and modified it to work for my specific purpose. The
only thing I can't seem to get it to do is start its file listing in
the second row ("B2"). Thanks in advance

Sub ListFiles02()
'Using FileSearch to list the files in a directory
Dim i As Integer
i = 1
With Application.FileSearch
.NewSearch
.LookIn = "G:\06_Drawings\Drafting System\Standards\Blocks\Casework"
.Filename = "*.dwg"
.SearchSubFolders = True
'.SearchFolders = False
.Execute
For i = 1 To .FoundFiles.Count
Range("B" & i).Value = .FoundFiles(i)
Range("C" & i).Value = FileDateTime(.FoundFiles(i))
'Range("D" & i).Value = FileLen(.FoundFiles(i))
Next


End With


End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default List Files in a Directory

You need to add 1 to i, like so:

For i = 1 To .FoundFiles.Count
Range("B" & i+1).Value = .FoundFiles(i)
Range("C" & i+1).Value = FileDateTime(.FoundFiles(i))
'Range("D" & i+1).Value = FileLen(.FoundFiles(i))
Next


On Sat, 17 Dec 2005 22:13:07 -0000, wrote:

I have gotten this code from a previous post (Thank You "KAAK", this
runs very fast) and modified it to work for my specific purpose. The
only thing I can't seem to get it to do is start its file listing in
the second row ("B2"). Thanks in advance

Sub ListFiles02()
'Using FileSearch to list the files in a directory
Dim i As Integer
i = 1
With Application.FileSearch
.NewSearch
.LookIn = "G:\06_Drawings\Drafting System\Standards\Blocks\Casework"
.Filename = "*.dwg"
.SearchSubFolders = True
'.SearchFolders = False
.Execute
For i = 1 To .FoundFiles.Count
Range("B" & i).Value = .FoundFiles(i)
Range("C" & i).Value = FileDateTime(.FoundFiles(i))
'Range("D" & i).Value = FileLen(.FoundFiles(i))
Next


End With


End Sub




--
------------------
Darren
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default List Files in a Directory

That did it! This is the fastest file listing code that I have used
(16,331 files in less than a minute). Thanks again for the replies.

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
Combo box with list of xls files in a directory excelguy Excel Discussion (Misc queries) 0 November 27th 06 02:53 PM
List of Files in A Directory JaneC Excel Discussion (Misc queries) 2 February 18th 06 12:11 PM
make a list of files in a directory GFN Excel Programming 2 July 29th 05 07:49 AM
Directory List of Excel Files No Name Excel Programming 6 May 18th 04 05:22 PM
list box- list all files ina directory suee Excel Programming 9 April 7th 04 02:32 AM


All times are GMT +1. The time now is 08:16 AM.

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

About Us

"It's about Microsoft Excel"