check folder event

M

Mark

I wonder if it possible write in VBA code(event) check
content some folder (all the time):
If amount files (different type files in c:\Mytest) is
greatest from 2 then msgbox "There is above 2 files in
folder".
I assume code should be in personal.xls and application
(Excel) opened continuously.

Can someone please suggest the best way to do this?

Regards
Mark
 
N

Nikos Yannacopoulos

Mark,

Try this piece of code:

Dim f, fs, fcount
fldr = "C:\Mytest"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.Getfolder(fldr)
fcount = f.Files.Count
If fcount > 2 Then
MsgBox "There are more than 2 files in the folder"
End If

HTH,
Nikos
 
M

Mark

Hi Nikos!
it work fine but lacking some event do continously check
files in folder - at me, files in folder appear and
disappear.
Best Regards
Mark
 
M

Mark

I'd like know exactly moment increase amount files (>2) in
folder.
Maybe vba don't have tools to do it or any tool very load
memory.
Regards
Mark
 
N

Nikos Yannacopoulos

Mark,

A timer function of some kind could be used to check periodically, e.g.
every second or every minute or whatever suits your needs... regrettably I
don't know of Excel VBA having this functionality, I think it doesn't;
Access does, and VB 6.0 does. I would use VB 6.0 to do it in a stand-alone
application, in a small .exe that would take up minimal system resources. Do
you have VB Studio? If yes, I can tell you how to do it. If no, I could do
it for you and mail it, if you mail me your address... unless someone knows
better and enlighten us on how to use a timer control in Excel.

Nikos
 
N

Nikos Yannacopoulos

Tom,

That's great, it wouldn't feel right if there wasn't a way. Thanks to both
you and Chip.

Nikos
 
Top