CQG API 4.0 - Revised
IsReady Event
See Also  Send Feedback
ready_status

readyStatus should reflect the Excel.Application.Ready flag. If Application.Ready is True, then readyStatus should be assigned rsReady. If Application.Ready is False then readyStatus should be assigned rsNotReady.

If CQGCEL gets rsBusy or rsNotReady, the attempt is repeated after the timeout, until CQGCEL gets rsReady and becomes able to process its own events.

CQGCEL Interface : IsReady Event

Glossary Item Box

Description

This event was added especially to be used in Excel macros. It is fired every time before any other event is fired to check the Excel readiness to receive user events.

Generally it can be used for similar purposes from other host applications to control event flow by informing CQG API about readiness to receive events.

Syntax

Visual Basic
Public Event IsReady( _
   ByRef ready_status As eReadyStatus _
)

Parameters

ready_status
ValueDescription
rsBusy

The host application (MS Excel) is in edit mode.

rsNotReady

The host application (MS Excel) isn't ready (when Application.Ready = False).

rsReady

The host application (MS Excel) is ready (when Application.Ready = True).

readyStatus should reflect the Excel.Application.Ready flag. If Application.Ready is True, then readyStatus should be assigned rsReady. If Application.Ready is False then readyStatus should be assigned rsNotReady.

If CQGCEL gets rsBusy or rsNotReady, the attempt is repeated after the timeout, until CQGCEL gets rsReady and becomes able to process its own events.

Remarks

The firing of this event is controlled by the CQGAPIConfig.ReadyStatusCheck property. If its ReadyStatusChecked member is set to rscOn IsReady will be fired; if ReadyStatusChecked is set to rscOff IsReady won't be fired.

If you are using OfficeXP and higher you should correctly handle IsReady event and ready status check configuration should be set to rscOn.

All implementations except Excel macros can set ready status check configuration to rscOff in order not to handle IsReady events.

The IsReady event was added taking into account Excel's Application.Ready flag, which reflects the Excel readiness to receive user events. Sometimes Excel just does not "get" user events but stays silent. In this case, the user has no means to know did his event pass or no. The IsReady event can be used to avoid such cases.

Important: DoEvents should not be called in this event handler.

Example

See implementation of IsReady event handler in CQGCEL Example.

 

IsReady event handling in Office 2000 Copy Code
Private Sub cel_IsReady(readyStatus As CQG.eReadyStatus)
    ' Office 2000 does not have Application.Ready flag,
    ' hence always return rsReady
    readyStatus = rsReady
End Sub

 

How to programmatically retrieve Excel version Copy Code
Private Function IsReadyFlagExist() As Boolean
    'Get excel major version
    Dim ExcelMajorVersion As Integer
    ExcelMajorVersion = CInt(Left$(Application.Version, InStr(Application.Version, ".") - 1))
    If ExcelMajorVersion > 9 Then ' Excel 2002 and higher
        IsReadyFlagExist = True
    Else
        IsReadyFlagExist = False
    End If
End Function

See Also