Automating keystrokes is possible from Excel but not very stable.
This sub routine should give you an idea . . . .
'
'=========================================
'
Sub Bloomberg(Isin As String, BondType As String, Command As String, Optional Panel As Integer = 1)
'Bond type is the bloomberg yellow key as a string : "Corp", "Govt" etc
'Command can be DES or ALLQ or whatever
'Panel is 1 to 4 indicating the panel that is used
Dim blp As Variant
On Error GoTo ErrorHandler
If Panel < 1 Or Panel > 4 Then
MsgBox "Panel must be between 1 and 4.", vbExclamation
GoTo ErrorHandler
End If
Application.DisplayAlerts = False
On Error Resume Next
blp = DDEInitiate("winblp", "bbk")
Application.DisplayAlerts = True
On Error GoTo 0
Call DDEExecute(blp, "<blp-" & Panel - 1 & ">" & Command & " <GO>")
Call DDETerminate(blp)
Exit Sub
ErrorHandler:
End Sub
'
'=========================================
'
Else would be surprised if you wern't able to put the data in the api (type WAPI <GO> ) for bbg's help on this.
All possible bloomberg fields are in your C:\Program Files\Bloomberg\Bloomberg_03\API\BBFIELDS.TBL file
Wow, there are lots of experts on this forum...
Thanks a lot!
To confirm, I don't want to use the Bloomberg Excel interface to do the stuff. I really want a simulation of human being with key strokes to automate things. That's more generic and versatile I think. Does the code above do the desired job?
For example, the keystrokes I would like to use:
(1) In the Excel sheet, there is a column with a list of tickers for CDS for different firms;
(2) In BB, type
the ticker, then CDS, then "hp" historical price,
(3) I made a "button" already in the BB, called "hp1", it will give me a certain window of past historical price.
I just need to assign that "hp1" to a command, or a special key.
(4) For each ticker, I just need to invoke that "hp1", it will give me the historical price in that past time window.
(5) Need to simulate "copy&paste" those historical price quotes into Excel,
(6) Repeat the above for thousands of times for different ticker...
Any thoughts? Thanks a lot!