question

Upvotes
Accepted
1 1 0 2

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

eikoneikon-data-apieikon-com-apiconnectionvba
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvotes
Accepted
39.4k 77 11 27

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.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi Alex, I actually tried using OnStatusChanged in the code. However this didn't work because the application did not even connect to Eikon, the initialization failed, so the code will never hit OnStatusChanged function or continue with other parts of the code.

When you added the event handler for OnStatusChanged event, did you remove the endless loop and the destroying of EikonDesktopDataAPI object from your Start procedure? The following code should be deleted from Start procedure:

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

The call to RequestData procedure should be moved to OnStatusChanged event handler.

Yes, I tried to use the VBA code posted on the developer site. However the initialization status always shows a fail. I also have a c# app to connect to Eikon and it always give me disconnected status. And every time I download a new Eikon installer it always showed Download failed so I cannot continue to install the program

Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.