Results 1 to 6 of 6

Thread: Excel freezing when using .ontimer event

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Senior Member
    Join Date
    Apr 2011
    Posts
    190
    Rep Power
    15
    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
    Last edited by Rasm; 11-23-2012 at 04:47 AM.
    xl2007 - Windows 7
    xl hates the 255 number

Similar Threads

  1. Worksheet Change Event
    By jamilm in forum Excel Help
    Replies: 2
    Last Post: 12-29-2012, 12:06 AM
  2. Left and Right Mouse Click Event
    By PcMax in forum Excel Help
    Replies: 10
    Last Post: 11-24-2012, 04:54 AM
  3. Worksheet_Change event
    By Excelfun in forum Excel Help
    Replies: 2
    Last Post: 11-21-2012, 07:24 AM
  4. Event target range
    By bobkap in forum Excel Help
    Replies: 3
    Last Post: 09-13-2012, 05:34 AM
  5. help with after insert event in Access 10
    By richlyn in forum Access Help
    Replies: 9
    Last Post: 03-03-2012, 10:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •