Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
use the filesystemobject
Set fso = CreateObject("Scripting.FileSystemObject") of the top of my head, I believe there is a files object so fso.files.count 0 check the filesystemobject under help and you will see lots of examples Paul "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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
open all files in directory | Excel Discussion (Misc queries) | |||
temporary directory files | Excel Discussion (Misc queries) | |||
Files in a directory? | Excel Discussion (Misc queries) | |||
Open files in directory | Excel Programming | |||
run macro for all files in the directory | Excel Programming |