LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default Check if directory empty OR no of files in directory.

Sub CountFiles()
Dim iCount As Integer
Dim x As Integer
Dim strPath As String

strPath = "C:\ParentFolder\TargetFolder\"
x = Len(Dir(strPath))
If x < 0 Then
Do
iCount = iCount + 1
x = Len(Dir)
Loop Until x = 0
MsgBox "There are " & iCount & " file(s)."
Else
MsgBox "There are no files."
End If
End Sub
--
George Nicholson

Remove 'Junk' from return address.


"Michael Beckinsale" wrote in message
...
Hi All,

I am in the middle of writing code for a spreadsheet solution and need to
check whether a specific directory is empty or not.

Can anybody tell me what the code is to do that please. ?

Alternatively does anybody know the code to count the number of files in a
directory ? I could then apply an IF 0 type statement to achieve the same
result.

All suggestions gratefully received.

Regards

Michael beckinsale




 
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
open all files in directory davethewelder Excel Discussion (Misc queries) 2 August 26th 08 02:01 PM
temporary directory files IMJQT Excel Discussion (Misc queries) 1 April 9th 08 12:30 AM
Files in a directory? Greg B Excel Discussion (Misc queries) 5 May 11th 05 09:46 PM
Open files in directory V. Roe Excel Programming 2 November 4th 03 07:45 PM
run macro for all files in the directory igor Excel Programming 3 July 17th 03 03:48 PM


All times are GMT +1. The time now is 09:05 AM.

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

About Us

"It's about Microsoft Excel"