cham.miller
New Member
- Joined
- Oct 8, 2010
- Messages
- 5
I am working on writing a VBScript to run an excel macro only if a particular file exists in a specified directory. If the file does not exist, I would like the script to wait 10 minutes and check for the file again. Ideally, this script would continue running until a file is dropped into the directory, at which point the file would be detected and an excel macro would start. At the completion of that macro, the script would resume checking the same directory (assuming the file that triggered the macro was moved out of that directory once the macro had finished).
I am pretty familiar with excel macros, but have never worked with loops. I don't know if a DoWhile or DoUntil loop would be best.
If it helps, I have a large set of macros which take multiple files in specific locations and build a set of PDF reports from those files. I need to be able to drop my original files into specific directories and have the macro automatically build my report and move the files to another directory, then resume checking for new files.
The only VBScript code I have so far (copied and pasted form various sources) is:
Option Explicit
DIM fso
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists("C:\Documents and Settings\Cham Miller\Desktop\Test\Test1.txt")) Then
Application.run ("personal.xlsb!MFG37cBladeReport")
Else WScript.Sleep 10000
End If
DoUntil '??
Loop
Thanks in advance,
Charles
I am pretty familiar with excel macros, but have never worked with loops. I don't know if a DoWhile or DoUntil loop would be best.
If it helps, I have a large set of macros which take multiple files in specific locations and build a set of PDF reports from those files. I need to be able to drop my original files into specific directories and have the macro automatically build my report and move the files to another directory, then resume checking for new files.
The only VBScript code I have so far (copied and pasted form various sources) is:
Option Explicit
DIM fso
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists("C:\Documents and Settings\Cham Miller\Desktop\Test\Test1.txt")) Then
Application.run ("personal.xlsb!MFG37cBladeReport")
Else WScript.Sleep 10000
End If
DoUntil '??
Loop
Thanks in advance,
Charles