OK -- got it sorted --- The SLEEP --- I use to pause a thread --- however it does mean that all code in XL is not being executed --- so dont use SLEEP as a timer --- However I am reading CSV file every 6 seconds -- so sometimes I have a sharing conflict -- before I open any new CSV file(s) I execute SLEEP for 500 milliseconds --- this allow the 3rd party application to finish saving the data to the CSV file before I try to read it --- After I have read and parsed the CSV file -- I kill it -- again I am using a SLEEP of 500 MS --- else the code may get ahead of itself and cannot kill the file as the other sub has not closed it yet --- strange but true. So that is how I use the SLEEP command. Next I wrote my own timer --- it contains the DoEvents statement --- so what this does it releases the code and hands control to Windows. So that works very well to 'distract' xl2007 ----- and temporaly stop executing xl code. I am writting to a cell what procedure is being processed as I could not use the debugger as excel froze up.
Anyway -- just wanted to share in case anybody else is having trouble using a timer in combination with I/O operations.
The TimeOnOFF can be toggled using code to be True/False -- It is dimmed as a Public Boolean variable
Code:
Public Sub TimerXX
Application.StatusBar = "Timer On"
SS = Second(Now) + DelayTimeSeconds
While TimeOnOFF = True
If Second(Now) > SS Then
Call ReadDataFromAnalyzer
SS = Second(Now) + DelayTimeSeconds
End If
DoEvents
Wend
Application.StatusBar = "DataPickUp = Off"
End Sub
Bookmarks