I think he said what he meant.
he said:
if now() - timestamp(mary.xls) < 1 hour then
run my code
else
wait until mary.xls is less than an hour old
run my code
end if
either way, he wants to run the code, so it can be changed to:
Do While now() - timestamp(mary.xls) > 1 hour
Loop
Run my code
You might want to put something into your loop to give an option to get out,
so that it isn't an endless loop... or you might not, depending upon what YOU
want.
You can get the timestamp of mary.xls using the FileSystemObject
Here's a sample:
Sub sbTest()
Const cnFile = "c:\test.xls"
Dim myFileTime As Date
Dim i As Long
myFileTime = fnFileDate(cnFile)
MsgBox Now() - myFileTime
Do While Now() - myFileTime > (1 / 24)
i = i + 1
If i > 10000 Then
Exit Do
End If
Loop
MsgBox "I can go!"
End Sub
Function fnFileDate(filename) As Date
'dimension variables
Dim fs As Object
Dim f As Object
'assign variables
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.getfile(filename)
fnFileDate = f.DateLastModified
End Function
You'll want to take that Exit Do out and work it up a little... I just put
that in three to get myself out of the loop on the test, because my test.xls
file is 65 days old and I got into the loop!
> <<When I run a Macro, in the middle of the process, I would like to hold
> Macro running until the periods between the last updated time for specific
[quoted text clipped - 5 lines]
> Are you sure you meant instead to wait until 1 hour has passed, then update
> the file?
Bill Renaud - 28 Sep 2007 17:27 GMT
OK, so Eric's program is waiting for another process to update the file,
before it updates everything. I guess I missed that concept!
You might want to put some sort of 5 minute wait inside the loop, so that
your routine is not checking the file constantly! This might tie up the
file server so much that the other process would have a difficult time
making its update, which your routine is waiting on.

Signature
Regards,
Bill Renaud