Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default How to find and count # of files in a directory

Hi I am trying to count the number of files in directory + subs, when I try I
get all files in the directory but not in the subs or I can get all thats in
a sub but not sub and directory. Can anybody help please
Charles
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to find and count # of files in a directory

Show the code you are using.

--
Regards,
Tom Ogilvy


"vqthomf" wrote:

Hi I am trying to count the number of files in directory + subs, when I try I
get all files in the directory but not in the subs or I can get all thats in
a sub but not sub and directory. Can anybody help please
Charles

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default How to find and count # of files in a directory

The code I am using is from "VBA Developer's Handbook which only have code
for Directory or subs there is not much in the help files I can get it to
look into the directory and subs?
Regards
Charles


"Tom Ogilvy" wrote:

Show the code you are using.

--
Regards,
Tom Ogilvy


"vqthomf" wrote:

Hi I am trying to count the number of files in directory + subs, when I try I
get all files in the directory but not in the subs or I can get all thats in
a sub but not sub and directory. Can anybody help please
Charles

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default How to find and count # of files in a directory

I think you can use something like this to get files from a folder and all
it's subfolders:

Sub getFiles(strFolder As String)

Set fso = CreateObject _
("Scripting.FileSystemObject")

If Not fso.FolderExists(strFolder) Then
Debug.Print "The folder doesn't exist"
Exit Sub
End If

Set folder = fso.GetFolder(strFolder)

For Each file In folder.Files
Debug.Print file.Path
Next

For Each subFolder In folder.Subfolders
Call getFiles(subFolder.Path)
Next

End Sub


If you need only the count of files you can ad a counter variable.

--
urkec


"vqthomf" wrote:

The code I am using is from "VBA Developer's Handbook which only have code
for Directory or subs there is not much in the help files I can get it to
look into the directory and subs?
Regards
Charles


"Tom Ogilvy" wrote:

Show the code you are using.

--
Regards,
Tom Ogilvy


"vqthomf" wrote:

Hi I am trying to count the number of files in directory + subs, when I try I
get all files in the directory but not in the subs or I can get all thats in
a sub but not sub and directory. Can anybody help please
Charles

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
Choosing certain files in directory and one in particular JEFF Excel Programming 0 July 23rd 05 11:39 PM
Files in a directory? Greg B Excel Discussion (Misc queries) 5 May 11th 05 09:46 PM
Check if directory empty OR no of files in directory. Michael Beckinsale Excel Programming 2 December 4th 03 10:12 PM
find files and copy to new directory arne Excel Programming 3 November 26th 03 07:26 PM
Open files in directory V. Roe Excel Programming 2 November 4th 03 07:45 PM


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