vba 如何在vba的excel中刷新/加载RTD Bloomberg函数(BDH)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12856979/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to refresh/load RTD Bloomberg function (BDH) in excel in vba
提问by Larry
I would like to know if there's a way in VBA code forcing the bloomberg functions (In spreadsheet) to update its value( Any BDH functions)
我想知道 VBA 代码中是否有办法强制彭博函数(在电子表格中)更新其值(任何 BDH 函数)
Targeting Developers have faced similar issue/ have Bloomberg terminal
目标开发者面临类似问题/拥有彭博终端
What have I tried--
我试过什么——
Application.RTD.RefreshData
Application.RTD.throttleInterval = 0
Application.CalculateFull
The BDH function do not reload themselve.
BDH 功能不会自行重新加载。
The only way I can refresh them now is : I click the "Refresh WorkBook" Button on the Ribbon of the BloomBerg add-in.
我现在可以刷新它们的唯一方法是:单击 BloomBerg 加载项功能区上的“刷新工作簿”按钮。
Since the Bloomberg Add-in is locked in VBE, I cannot find out the necessary code. Am I missing any Bloomberg Reference? Can any Bloomberg expert/user point me in the right direction? Thanks.
由于彭博插件被锁定在 VBE 中,我无法找到必要的代码。我是否缺少任何彭博参考资料?任何彭博专家/用户都可以指出我正确的方向吗?谢谢。
采纳答案by Larry
I did a searching of the keyword "refresh" in the xla by opening it in notepad. Found the following targets:
我通过在记事本中打开它在 xla 中搜索了关键字“刷新”。找到以下目标:
RefreshAllWorkbooks
blpmain.xla!RefreshAllStaticData
blpmain.xla!'RefreshWorkbookFundamentalsData
blp.xla!IsBlpRefreshAvailable
I tried them out one by one, the first 2 works by calling:
我一个一个地尝试了它们,前两个通过调用起作用:
Application.run "RefreshAllWorkbooks"
Application.run "RefreshAllStaticData"
But not calling them alone ( I guess it's because I somehow can call protected PUBLIC procedure using Application.run)
但不是单独调用它们(我想这是因为我可以使用 Application.run 以某种方式调用受保护的 PUBLIC 过程)
RefreshAllWorkbooks
or
或者
RefreshAllStaticData
Thanks for all the help
感谢所有的帮助
回答by RECosgrove
I've found that changing something in the BDH formula would cause a refresh. Find and replace the =
sign would do the tick.
我发现更改 BDH 公式中的某些内容会导致刷新。查找和替换=
标志会做勾号。
Public Sub Recalc()
Dim ws As Worksheet, FormulaCells As Range, c As Range
Application.Calculation = xlCalculationManual
For Each ws In ThisWorkbook.Worksheets
On Error Resume Next
ws.Activate
Set FormulaCells = ws.UsedRange.SpecialCells(xlCellTypeFormulas).Cells
If Err = 0 Then
For Each c In FormulaCells
c.Formula = Replace(c.Formula, "=", "=")
Next 'c
Else
Err.Clear
End If
Next 'ws
Application.Calculation = xlCalculationAutomatic
End Sub
回答by Kenny
This works for me:
这对我有用:
WS.Select
WS.Range("A5").Select 'the cell that contains the BDH function
Application.Run "RefreshCurrentSelection"
回答by assylias
I have never managed to do what you ask for. The only reliable way I have found to get up-to-date data is by calling the API directly from VBA with BLP_DATA_CTRLLib.BlpData
, waiting for the answer, and putting the result into a sheet.
我从来没有按照你的要求去做。我发现获取最新数据的唯一可靠方法是直接从 VBA 调用 API BLP_DATA_CTRLLib.BlpData
,等待答案,然后将结果放入工作表中。
With regards to opening password protected VBA code, a google or stackoverflow search should give you your answer.
关于打开受密码保护的 VBA 代码,谷歌或 stackoverflow 搜索应该会给你答案。