Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Read Directory and count files 1

Status
Not open for further replies.

ninash

Technical User
Jul 6, 2001
163
GB
Hi All,

I need to read a directory and count the files contained in it. Also I need to read the files names for file processing.
Any help you can provided will be very welcome

Tony
 
Hi
Just as a starting point for you

Code:
Sub sell()
Dim fso As Object
Dim fold
Dim file
Dim s As String

s = "C:\My Documents\YOUR FOLDER NAME HERE"

Set fso = CreateObject("scripting.filesystemobject")
Set fold = fso.getfolder(s)

With fold
    For Each file In .Files
        MsgBox file.Name
    Next
    MsgBox "There are " & .Files.Count & " files in folder " & s
End With

Set fso = Nothing
Set fold = Nothing
End Sub

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
You may also take a look at the Dir function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks Loomah

Just what I needed to get the job done

You are a star but I will give you another to make you shine even brighter

Ta
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top