Wait for the existance of a file, then run macro

tacieslik

Registered User.
Local time
Today, 23:46
Joined
May 2, 2001
Messages
244
I need to run a macro when a file called 'Paused.ini' exists in the folder c|:\ABCD\123. I guess I need to have a loop in the code to allow it to wait for the file to exist, but I don't know what to do next.

Any ideas would be great.
 
With Application.FileSearch
.NewSearch
.LookIn = "c\:ABCD\123."
.SearchSubFolders = False
.FileName = "Paused.ini"

If .Execute() > 0 Then
Run your code
Else
Exit Sub
End If
End With
 
Last edited:
Hi Nero,

I am using the sample you placed here, but I don't really understand the .execute() method. I know it returns the file object, but could you explain it a little more to me? Is this method used for anything other than FileSearch/FileFind? Could it be used with a Power Point slide show to check for the existence of a slide or bookmark in a Word doc? Do you know what the AlwaysAccurate boolean can do for this example?

Thanks in advance,
 
Hi Nero,

I am using the sample you placed here, but I don't really understand the .execute() method. I know it returns the file object, but could you explain it a little more to me? Is this method used for anything other than FileSearch/FileFind? Could it be used with a Power Point slide show to check for the existence of a slide or bookmark in a Word doc? Do you know what the AlwaysAccurate boolean can do for this example?

Thanks in advance,
 
Basically the
Code:
If .execute() >0 Then
means that if the file search finds the file (or any number of files depending on what you are trying to do) it will return a non 0.
If it does not find any files it will return a 0.

I have not tried it with any other office apps so I can't answer that.
As for the AlwaysAccurate boolean, I've never used it so I can't answer that either.
Not much help I'm afraid.
 
Sorry for the delay Nero,

That's great, It works well!

Kind regards,
TAC
 

Users who are viewing this thread

Back
Top Bottom