_Application.OnTime Method

Schedules a procedure to be run at a specified time in the future (either at a specific time of day or after a specific amount of time has passed).

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Syntax

'Declaration
Sub OnTime ( _
    EarliestTime As Object, _
    Procedure As String, _
    LatestTime As Object, _
    Schedule As Object _
)
'Usage
Dim instance As _Application
Dim EarliestTime As Object
Dim Procedure As String
Dim LatestTime As Object
Dim Schedule As Object

instance.OnTime(EarliestTime, Procedure, _
    LatestTime, Schedule)
void OnTime(
    Object EarliestTime,
    string Procedure,
    Object LatestTime,
    Object Schedule
)

Parameters

  • EarliestTime
    Type: System.Object

    Required Object. The time when you want this procedure to be run.

  • Procedure
    Type: System.String

    Required String. The name of the procedure to be run.

  • LatestTime
    Type: System.Object

    Optional Object. The latest time at which the procedure can be run. For example, if LatestTime is set to EarliestTime + 30 and Microsoft Excel is not in Ready, Copy, Cut, or Find mode at EarliestTime because another procedure is running, Microsoft Excel will wait 30 seconds for the first procedure to complete. If Microsoft Excel is not in Ready mode within 30 seconds, the procedure won’t be run. If this argument is omitted, Microsoft Excel will wait until the procedure can be run.

  • Schedule
    Type: System.Object

    Optional Object. True to schedule a new OnTime procedure. False to clear a previously set procedure. The default value is True.

Remarks

Use Now+TimeValue(time) to schedule something to be run when a specific amount of time (counting from now) has elapsed. Use TimeValue(time) to schedule something to be run a specific time.

See Also

Reference

_Application Interface

_Application Members

Microsoft.Office.Interop.Excel Namespace