question

Upvotes
Accepted
1 0 1 1

VBA DEX2 problems with the OnUpdate call

Dear developer community members,

I have a question from my customer below and I am hopping to get some help here:tr-testtrtemplate.zip

I have been trying to use https://developers.thomsonreuters.com/sites/default/files/Eikon_for_Developers_09032016.pdf to access the data to replace some of my Bloomberg functions.

There seem to be a number of issues with the code in this pdf. Initially I tried to use the code from p117 to 119 but there were too many errors.

So, I cut the code back and debugged/fixed most of the issues so that I could get access (see attached). However, I am still having problems with the OnUpdate call, it doesn't seem to get triggered when data is returned and so I can't loop efficiently.

Can you have a look at the attached and let me know where its going wrong.

eikoneikon-com-api
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,

As your query is related to Eikon COM, I moved it to this Eikon COM group.

Kind regards,
AHS

@thomas tan

Thank you for your participation in the forum.

Is the reply below satisfactory in resolving your query?

If so please can you click the 'Accept' text next to the appropriate reply. This will guide all community members who have a similar question.

Thanks

AHS

1 Answer

· Write an Answer
Upvotes
Accepted
79.2k 251 52 74

I have modified your code a bit and found that OnUpdate is called properly.

I have added the code to call WaitforResponse and reset the value of m_hasReceivedResponse to false.

Sub getTR()
    Dim c As Range, d As Range
    Dim i As Range, j As Range
    Dim strFields As String, strCurr As String
    Set MyDex2Mgr = CreateDex2Mgr()
    Set MyDex2MgrADC = MyDex2Mgr  
    ' Initialise using the DE_MC_ADC_POWERLINK enumeration
    MyDex2Cookie = MyDex2MgrADC.Initialize(DE_MC_ADC_POWERLINK)
    Dim DataStatus As Dex2Lib.DEX2_DataStatus
    'compile a list of strings
    strFields = "TR.ISPeriodEndDate"
    For Each d In Range("TRCodes")
        If d.Offset(0, 1) <> "" Then
            strFields = strFields & "," & d.Value
        End If
    Next d
   
    If Len(strFields) > 0 Then
        'loop for every stock and request data
       For Each c In Range("RICCodes")
            ' And create an RData object.
            Set MyDex2RData = MyDex2Mgr.CreateRData(MyDex2Cookie)
            'get Currency.
            m_hasReceivedResponse = False
            With MyDex2RData
                .InstrumentIDList = c.Value
                .FieldList = "TR.CompanyReportCurrency"
                .DisplayParam = "RH:In CH:Fd"
                .Subscribe
            End With ' curn:USD
            WaitforResponse
            strCurr = MyDex2RData.Data(1, 1)
            strCurr = "USD"
            If Len(strCurr) > 0 Then
                Set MyDex2RData = MyDex2Mgr.CreateRData(MyDex2Cookie)
                'Before using the input parameters as one would for the TR() function.
                With MyDex2RData
                    .InstrumentIDList = c.Value
                    .FieldList = strFields
                    .RequestParam = "FP:FY2014;FY1980 reportingstate:rsdt CURR:USD"
                    .Subscribe
                End With ' curn:USD
                m_hasReceivedResponse = False
                WaitforResponse
                PrintArray MyDex2RData.Data, ActiveWorkbook.Worksheets("Sheet2").Range("A1")
                ActiveWorkbook.Worksheets("Sheet2").Range("A1").Value = strCurr
            End If
            Set MyDex2RData = Nothing
        Next c
    End If
End Sub
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.

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.