ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   check folder event (https://www.excelbanter.com/excel-programming/301804-check-folder-event.html)

Mark[_17_]

check folder event
 
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

Nikos Yannacopoulos[_5_]

check folder event
 
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

"Mark" wrote in message
...
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




Mark[_17_]

check folder event
 
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
-----Original Message-----
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

"Mark" wrote in message
...
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



.


Mark[_17_]

check folder event
 
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

-----Original Message-----
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

"Mark" wrote in message
...
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



.


Nikos Yannacopoulos[_5_]

check folder event
 
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


"Mark" wrote in message
...
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

-----Original Message-----
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

"Mark" wrote in message
...
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



.




Tom Ogilvy

check folder event
 
Look at Chip Pearson's page on Application.OnTime to run your macro

http://www.cpearson.com/excel/ontime.htm

--
Regards,
Tom Ogilvy

"Mark" wrote in message
...
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

-----Original Message-----
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

"Mark" wrote in message
...
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



.




Nikos Yannacopoulos[_5_]

check folder event
 
Tom,

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

Nikos

"Tom Ogilvy" wrote in message
...
Look at Chip Pearson's page on Application.OnTime to run your macro

http://www.cpearson.com/excel/ontime.htm

--
Regards,
Tom Ogilvy

"Mark" wrote in message
...
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

-----Original Message-----
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

"Mark" wrote in message
...
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


.







All times are GMT +1. The time now is 10:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com