tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,832
- Office Version
- 365
- 2019
- Platform
- Windows
The following code is taken from here:
This is one such snippet taken from page 90:
I assume this code ought to be placed in a class module because of Dim WithEvents.
The code doesn't compile. I think this line is faulty:
as Sub is a keyword.
If I changed the Sub to abc for example, it does compile.
Then in a regular module, I write:
It doesn't crash but it appears nothing happens when the code runs all the way to the end.
I thought it was meant to return the equivalent of BDP("IBM US Equity", "LAST_PRICE").
Can someone please help.
Thanks
Code:
https://data.bloomberglp.com/professional/sites/10/2017/03/BLPAPI-Core-Developer-Guide.pdf
This is one such snippet taken from page 90:
Code:
'Bloomberg Excel Formula:
'BDP("IBM US Equity", "LAST_PRICE")
'
'Equivalent COM v3 Data Control Subscription Code:
Dim WithEvents session As blpapicomLib.session
Sub SomeSub
Set session = New blpapicomLib2.session
session.QueueEvents = True
session.Start
session.OpenService "//blp/mktdata"
Dim sub As blpapicomLib2.SubscriptionList
Dim cid As blpapicomLib2.CorrelationId
Set sub = session.CreateSubscriptionList()
Set cid = session.CreateCorrelationId(1)
sub.Add "IBM US Equity", "LAST_PRICE", cid ' To set an update interval of, for e.g. 4 seconds, ' use this syntax instead: ' sub.AddEx "IBM US Equity", "LAST_PRICE", "interval=4.0"
session.Subscribe sub
I assume this code ought to be placed in a class module because of Dim WithEvents.
The code doesn't compile. I think this line is faulty:
Code:
Dim sub As blpapicomLib2.SubscriptionList
as Sub is a keyword.
If I changed the Sub to abc for example, it does compile.
Then in a regular module, I write:
Code:
Dim a As Class1
Set a = New Class1
a.SomeSub
It doesn't crash but it appears nothing happens when the code runs all the way to the end.
I thought it was meant to return the equivalent of BDP("IBM US Equity", "LAST_PRICE").
Can someone please help.
Thanks