Viewing application.ontime scheduled events

  • Hi, everyone.


    I have a workbook with a scheduled event using application.ontime to close after 30 minutes of inactivity (activity defined as selecting a different cell in the worksheet). There is a bug in it somewhere that is causing the workbook to open up again later. I'm pretty confident that my syntax for unscheduling the event is correct, so I was wondering if there is a way to view all scheduled events within application.ontime. Can this be done? Seeing what is scheduled will help me troubleshoot.


    Just so you know how I'm working, here is the code I'm using below.


    Code
    Private Sub Workbook_Open()
    Call ResetTimer                                                                                             'Call the module to start a timer from this moment (used to auto close the workbook on inactivity)
    End Sub


    Code
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Call ResetTimer                                                                                             'Call the module to start a timer from this moment (used to auto close the workbook on inactivity)
    End Sub



  • Re: Viewing application.ontime scheduled events


    Hi,


    I'm guessing, based upon the first and last blocks of code within the BeforeClose event code that you posted, that this is a trimmed-down version of your code. Could it be that any of the other code is causing trouble (especially as you are driving the OnTime routine from a number of events and the BeforeClose event switches off EnableEvents)? Just a thought.


    The key with OnTime is passing the exact time in Ending it as was used to Start it. Could the ScheduledTime variable be being changed somewhere such that the time when switching off OnTime doesn't match the time when it was switched on?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!