MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Wait for File but dont hangup system


Posted by Mark Zebitz on April 12, 2000 4:50 AM

Do you know a way to wait and look for a file to arrive in a chosen
directory ??

Problem:
a) I have to create a ASCII file -> done
b) I have to tell a UNIX system to start a calculation -> done (by help
from allexperts !!- thanks)
c) Then I must wait for the UNIX to return a ASCII file to a certain
directory -> big problem !!!!
d) Then the ASCII file should be imported and the values placed in a
worksheet -> done

When I try working with the WAIT statement the system just hang-up for
between 1-4 minutes until the file arrive :-(

Result wanted:
I just what a TRUE return when the file are ready
maybe tell me in a msgbox.

I hope you have an idea for this problem....

System: Excel 97 on a WinNT system.


Posted by Ivan Moala on April 13, 2000 5:33 PM

You could try

Put in Thisworkbook MSexcel object;
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Excel.Range)
If Range("Z1") = False Then
Application.Run "FileCreated"
End If
End Sub


Pu into a Module;
Sub FileCreated()
Dim WhatFile As String
Dim Done


Done = Range("Z1")
If Done = "O/R" Then End
If Done Then End
WhatFile = Dir("D:\Myfile")
If WhatFile <> "" Then
MsgBox "File has been created!"
Range("Z1") = True
Else
Range("Z1") = False
End If
End Sub


Now @ cell Z1 or any other range out of the way
put "O/R" for over ride if you don't want the
Macro "FileCreated" to run BUT when you are ready
to start checking have some routine to delete this
and it will check to see if the file has been
created. Note: replace the "D:\Myfile" with your filename.

Ivan