![]() |
Polling directory for changes
Hi There,
I would like to verify whether there are changes on a certain text-file. Dave P. gave a link to the site of Randy Birch where he has some code which does -i think- exactly what I would like to test. I created the Userform ...Commandbuttons ..labels ...as he suggested. But do not succeed to get any data in it. Is it not possible to fire this code in Excel97 SR2? Why? If possible: How? Sige Van:Dave Peterson Onderwerp: Polling a directory for changes with Excel Datum:2002-03-01 I'm not quite sure if this is what you want, but you can get some code from Randy Birch's VBNet site to use API calls to watch a folder. Go to http://www.mvps.org/vbnet/ and search for FindChangeNotification. |
Polling directory for changes
If I recall correctly, Randy Birch uses a userform (albeit VB, not VBA) to show
how this works. You may want to post more info about what you tried. (I remember it working in 2002 when I was using xl97 SR2 and win98.) SIGE wrote: Hi There, I would like to verify whether there are changes on a certain text-file. Dave P. gave a link to the site of Randy Birch where he has some code which does -i think- exactly what I would like to test. I created the Userform ...Commandbuttons ..labels ...as he suggested. But do not succeed to get any data in it. Is it not possible to fire this code in Excel97 SR2? Why? If possible: How? Sige Van:Dave Peterson Onderwerp: Polling a directory for changes with Excel Datum:2002-03-01 I'm not quite sure if this is what you want, but you can get some code from Randy Birch's VBNet site to use API calls to watch a folder. Go to http://www.mvps.org/vbnet/ and search for FindChangeNotification. -- Dave Peterson |
Polling directory for changes
Hi Dave,
-I created the Userform like Randy says with the Commanbuttons, labels and listbox on it. -Put all his code into the userform -Changed just the "d:\dummy"-directory to mine ... And just now managed to get it working ...At least: Sort of!!! Problem is/was: Randy uses -I guess it is VB- : eg: -Private Sub Command1_Click() (obviously also for 2 and 3) -List1 While the VBA requires: -Private Sub CommandButton1_Click() -ListBox1 = The VB-names (like Command1_Click) are not compatible with VBA? Is there maybe a reference to set, so VBA understands the VB "completely"? = I managed to get it working: ie it polls for every change made on the specific text-file...Instantaneously: in nano-seconds ;o) ! ***BUT*** it is nearly impossible for me to "Stop Watching"/stop the polling ...or to End (unload) the Userform ... Excel behaves a bit like: not-responding, it sort of "hangs", "stalls". Only after 4-5 minutes, the userform will "Stop Watching" or "End". == Why? Sige "NOSPAM" to be removed for direct mailing... *** Sent via Developersdex http://www.developersdex.com *** |
Polling directory for changes
I don't know of any cross-reference document for VB to VBA.
I just found the workbook I used in 2001. I didn't have the same problem as you. If you want, I can email it to you to test. SIGE wrote: Hi Dave, -I created the Userform like Randy says with the Commanbuttons, labels and listbox on it. -Put all his code into the userform -Changed just the "d:\dummy"-directory to mine ... And just now managed to get it working ...At least: Sort of!!! Problem is/was: Randy uses -I guess it is VB- : eg: -Private Sub Command1_Click() (obviously also for 2 and 3) -List1 While the VBA requires: -Private Sub CommandButton1_Click() -ListBox1 = The VB-names (like Command1_Click) are not compatible with VBA? Is there maybe a reference to set, so VBA understands the VB "completely"? = I managed to get it working: ie it polls for every change made on the specific text-file...Instantaneously: in nano-seconds ;o) ! ***BUT*** it is nearly impossible for me to "Stop Watching"/stop the polling ...or to End (unload) the Userform ... Excel behaves a bit like: not-responding, it sort of "hangs", "stalls". Only after 4-5 minutes, the userform will "Stop Watching" or "End". == Why? Sige "NOSPAM" to be removed for direct mailing... *** Sent via Developersdex http://www.developersdex.com *** -- Dave Peterson |
Polling directory for changes
Hi Dave,
I tried it with a couple of other codes from Randy as well ... If I do not change eg. Command1_Click to CommandButon1_Click The code simply does not work ... Look forward to receive your file Dave! Sige "NOSPAM" to be removed for direct mailing... *** Sent via Developersdex http://www.developersdex.com *** |
Polling directory for changes
Hi Sige,
-I created the Userform like Randy says with the Commanbuttons, labels and listbox on it. -Put all his code into the userform -Changed just the "d:\dummy"-directory to mine ... And just now managed to get it working ...At least: Sort of!!! Problem is/was: Randy uses -I guess it is VB- : eg: -Private Sub Command1_Click() (obviously also for 2 and 3) -List1 While the VBA requires: -Private Sub CommandButton1_Click() -ListBox1 = The VB-names (like Command1_Click) are not compatible with VBA? Is there maybe a reference to set, so VBA understands the VB "completely"? Yes VB buttons are named Command# by default. It's not a problem - just rename your buttons same, as per the instructions given by Randy under "Form Code" on his page. In your form module you could "Replace" all "Command" with "CommandButton", but that's more convoluted. Similarly with other named controls like "List#" vs "ListBox#" ***BUT*** it is nearly impossible for me to "Stop Watching"/stop the polling ...or to End (unload) the Userform ... Excel behaves a bit like: not-responding, it sort of "hangs", "stalls". Only after 4-5 minutes, the userform will "Stop Watching" or "End". == Why? I tried Andy's code in XL97 & XL2K. In XL97 I also had a problem to "Stop Watching". However I changed the following line in "Command1_Click" watchStatus = WatchResume(hWatched, 100) to watchStatus = WatchResume(hWatched, 400) Maybe need a few button clicks but now it stops OK. In XL2K leaving the interval at 100 works just fine for me on the same machine - instant stop. I have no idea why the difference in XL97 vs XL2K. During the Loop "DoEvents" allows other events - such as the button click to stop the watch - to fire. For my purposes in my own app this is exactly what I DON'T want! But that's another issue. Regards, Peter T PS: the direct link to Randy's code is he http://vbnet.mvps.org/code/fileapi/watchedfolder.htm |
Polling directory for changes
Hi Peter,
Thx for the solution ...got an "instant stop" now as well! Sige :o) "NOSPAM" to be removed for direct mailing... *** Sent via Developersdex http://www.developersdex.com *** |
Polling directory for changes
Glad you found the solution. I won't send that other workbook.
(ok?) SIGE wrote: Hi Peter, Thx for the solution ...got an "instant stop" now as well! Sige :o) "NOSPAM" to be removed for direct mailing... *** Sent via Developersdex http://www.developersdex.com *** -- Dave Peterson |
Polling directory for changes
Not necesary anymore Dave,
Thanks for all your assitence though! Sige "NOSPAM" to be removed for direct mailing... *** Sent via Developersdex http://www.developersdex.com *** |
All times are GMT +1. The time now is 05:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com