Hello,
I am trying to use DfAddPeriod in VBA :
Public Function CreateAdxDateModule() As AdfinXAnalyticsFunctions.AdxDateModule Set CreateAdxDateModule = CreateReutersObject("AdfinXAnalyticsFunctions.AdxDateModule") End Function
CreateAdxDateModule.DfAddPeriod("FRA", "12/02/2021", "1M", "EMC:S")
But this does return a Type Mismatch error, what Am I doing Wrong ?
Kindly
Most likely you have a type mismatch in the assignment statement calling CreateAdxDateModule.DfAddPeriod("FRA", "12/02/2021", "1M", "EMC:S") expression. The above function returns a Variant(1 To 1, 1 To 2) array. How do you declare the variable you assign the result of CreateAdxDateModule.DfAddPeriod("FRA", "12/02/2021", "1M", "EMC:S") to? In other words in the statement below how do you declare the variable named "res"?
res = CreateAdxDateModule.DfAddPeriod("FRA", "12/02/2021", "1M", "EMC:S")
On a side note, rather than creating a public function that returns AdxDateModule object (which in your example is named CreateAdxDateModule), I would suggest declaring a variable at the module level to store an instance of AdxDateModule class. This way you only need to have one instance of this class, which you can access any time you need to call a method like DfAddPeriod, rather than creating a new instance of AdxDateModule every time you execute DfAddPeriod method. E.g.
Dim m_AdxDateModule As AdfinXAnalyticsFunctions.AdxDateModule Private Declare Function CreateReutersObject Lib "PLVbaApis.dll" (ByVal progID As String) As Object Sub Test() Dim res As Variant If m_AdxDateModule Is Nothing Then Set m_AdxDateModule = CreateReutersObject("AdfinXAnalyticsFunctions.AdxDateModule") res = m_AdxDateModule.DfAddPeriod("FRA", "12/02/2021", "1M", "EMC:S") Debug.Print res(1, 1) & ", " & res(1, 2) End Sub
VBA AdfinX Real Time Error Message ERROR #360f
VBA API - Fetch CF_CLOSE with DEX2 doesn't work
Can we download un-adjusted stock price under DEX2 COM API
Why doesn't Application.Run("RtGet","IDN",RIC,FID) work in Eikon for Excel VBA?
forecast dividend excel file not working anymore on excel 32b version 2003