Jon von der Heyden
MrExcel MVP, Moderator
- Joined
- Apr 6, 2004
- Messages
- 10,912
- Office Version
- 365
- Platform
- Windows
Hi
I believe I know the answer to this but I need to be absolutely sure before testing on bloomberg terminal.
Bloomberg method RefreshAllStatic data doesn't suspend execution therefore any code called directly after this method is called is likely to be executed before the refresh is complete. Suggestions so far (thanks Colin ) are to call RefreshAllStaticData and then use Ontime to call a routine that has the remaining code.
Am I correct in thinking that I can use Sleep API instead? Something like:
I believe I know the answer to this but I need to be absolutely sure before testing on bloomberg terminal.
Bloomberg method RefreshAllStatic data doesn't suspend execution therefore any code called directly after this method is called is likely to be executed before the refresh is complete. Suggestions so far (thanks Colin ) are to call RefreshAllStaticData and then use Ontime to call a routine that has the remaining code.
Am I correct in thinking that I can use Sleep API instead? Something like:
Code:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private mlngCALC_COUNT As Long
Public Sub RefreshData(ByVal rngTable As Range)
Const lngMaxCalcCount As Long = 50
Const lngMsIncrement As Long = 300
Dim lngMsSleep As Long: lngMsSleep = lngMsIncrement
bb_refresh:
mlngCALC_COUNT = mlngCALC_COUNT + 1
If mlngCALC_COUNT > lngMaxCalcCount Then
Call RaiseError("Calculation timed out!")
Else
Application.Calculation = xlCalculationAutomatic
BloombergUI.RefreshAllStaticData
[highlight]Sleep lngMsSleep[/highlight]
If IsCalculated(rngTable) Then
rngTable.Value = rngTable.Value
Application.Calculation = xlManual
Else
lngMsSleep = lngMsSleep + lngMsIncrement
GoTo bb_refresh
End If
End If
End Sub
Private Function IsCalculated(ByVal rngTable As Range) As Boolean
Const strProcessing As String = "#N/A Requesting Data..."
Const strLimit As String = "#N/A * Lmt"
With Application
IsCalculated = CBool(.CountIf(rngTable, strProcessing) = 0)
If Not IsCalculated Then
If .CountIf(rngTable, strLimit) Then
Call RaiseError("BB limits preventing calculation!")
End If
End If
End With
End Function
Last edited: