Using COM API in VBA code, suddenly cannot connect to Eikon Desktop

we are using COM API in the access VBA code to connect to Eikon Desktop, it worked very fine until one day it shows connection failed.

I have attached the VBA code. Since the code works before and if we switch the computer login profile to another user the code also works, we don't think it is the code has the problem.

So we suspect that the profile we used to login the computer has problem, but I am not sure where the problem could be.

Then we switched the profile and try to run the program. After a while, I got the error "ActiveX cannot create object" which indicates that it could not initialize the Eikon (no Eikon login page initialized). So I reinstall the Eikon on the computer under the new profile. Then we encountered the same problem again: cannot connect to Eikon desktop. Then we realized this might not related to profile used on the computer. We tried new version Eikon and old version Eikon and neither worked.

I just wonder if this issue related to Eikon itself, like reference or installation problem or it associated with the computer system, like firewall or registration key.

Sub Start()
If oEikonConnection Is Nothing Then Set oEikonConnection = New EikonDesktopDataAPILib.EikonDesktopDataAPI
oEikonConnection.Initialize
End If

Do Until oEikonConnection.Status
DoEvents
Loop
RequestData =>start to request data after connection

Set oEikonConnection = Nothing
End Sub

Best Answer

  • Alex Putkov.1
    Alex Putkov.1 ✭✭✭✭✭
    Answer ✓

    Calling DoEvents is no guarantee that the property of in-proc
    COM server will be updated. VBA is single threaded and EikonDesktopDataAPI COM
    object runs on the same thread as your loop. DoEvents should in theory yield
    the execution to allow events to be processed, but you cannot rely on it. I’ve
    seen it producing sporadic results in tests run one right after another on the
    same machine with the same code. Sometimes it works and sometimes it doesn’t.
    To have reliable behavior, instead of sitting in an endless loop
    waiting for the Status property to change, use OnStatusChanged event provided
    by EikonDesktopDataAPI COM object.

Answers