Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Getting file names in a directory

Hello,
Would anyone be able to tell me how to get a list of files
in a particular directory within a VBA routine in Excel
2003?

Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Getting file names in a directory

Try:

Sub xz()
Dim Files As Variant
Files = ""
Set fso = CreateObject("Scripting.FileSystemObject")
For Each File In fso.GetFolder("C:\AJAY").Files
Files = Files & "," & File.Name
Next
Files = Split(Mid(Files,2), ",")
Set fso = NOTHING
End Sub

NOTE:
1. Files is a zero-based variant array irrespective of your option base
setting.
2. This does NOT recurse flders below the one you specify, if any.

"John" wrote:

Hello,
Would anyone be able to tell me how to get a list of files
in a particular directory within a VBA routine in Excel
2003?

Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Getting file names in a directory

try
sub anotherfindfiles()
Application.ScreenUpdating = False
Dim FN As String ' For File Name
Dim ThisRow As Long
Dim FileLocation As String
FileLocation = "c:\myfolder\*.xls"

FN = Dir(FileLocation)
Do Until FN = ""
ThisRow = ThisRow + 1
Cells(ThisRow, 1) = FN
FN = Dir
Loop
Application.ScreenUpdating = True
End Sub
--
Don Guillett
SalesAid Software

"John" wrote in message
...
Hello,
Would anyone be able to tell me how to get a list of files
in a particular directory within a VBA routine in Excel
2003?

Thanks!



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
to convert all the file names in one directory to .xls? S.G.Pillai Excel Discussion (Misc queries) 2 September 27th 05 05:13 PM
Creating a macro that lists directory names within a directory.... Andy Excel Programming 4 November 28th 04 06:13 AM
Aquiring Directory names aking1987[_7_] Excel Programming 1 November 16th 04 07:06 PM
Aquiring Directory names aking1987[_6_] Excel Programming 1 November 16th 04 01:45 PM
get path - save new file - same sub-directory as existing file tegger Excel Programming 2 October 21st 03 10:45 AM


All times are GMT +1. The time now is 01:40 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"