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.
Best Answer
-
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 Sub0
Categories
- All Categories
- 6 AHS
- 38 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛