Checking the number of files in a folder using VBA
You can get the count of files in a folder as follows:
Function xx()
Set fso = CreateObject("Scripting.FileSystemObject")
xx = fso.getfolder("c:\ajay").Files.Count
Set fso = Nothing
End Function
"Bhupinder Rayat" wrote:
Hi all,
The following code saves the active spreadsheet into subfolders within
c:/inbox.
sPath = ActiveWorkbook.FullName
ActiveWorkbook.SaveAs "c:\Inbox\" & _
Range("C12") & "\" & ActiveWorkbook.Name
Kill sPath
ActiveWorkbook.Close
I want to write a piece of code that brings up a message when the specified
subfolder holds 15 files already, stating that this subfolder is 'fill up'
and to save the file in the next subfolder.
Is there any way that VBA can test this? I spoke to my lecturer and he said
there are sub-routines available to do this, but I have drawn a blank with my
research.
Any help would be much appreciated,
Thanks,
Bhupinder Rayat
|