Fortunately, there is one approach what you can use in VBA: Dynamic Data Exchange (DDE). DDE has its problems and in general, I try to avoid using it. However, it has its rare moments exactly for things like this. Instead of doing this process manually, I have a program which reads a list of required parameters and then prints out price documentations one by one by using DDE.
The point in my example given below is, that you will get the basic idea how you could use DDE for this particular type of problem. Then, you can work for developing your own solution. You can copy-paste the following program into a new VBA Standard Module.
Note: for this program you need to have active Bloomberg licence in your machine.
Option Explicit ' Private Const CONST_APP As String = "WINBLP" Private Const CONST_TOPIC As String = "BBK" ' Private channel As Long Private executionString As String ' Public Sub tester() ' On Error GoTo errHandler ' channel = DDEInitiate(CONST_APP, CONST_TOPIC) ' Dim executionString As String: executionString = createExecutionString("DE0001102317", "CBBT", "D", "B") DDEExecute channel, executionString ' DDETerminate channel Exit Sub errHandler: MsgBox "Undefined error", vbCritical, "Error" Exit Sub End Sub
Private Function createExecutionString(ByVal isinCode As String, _ ByVal provider As String, ByVal period As String, ByVal quoteType As String) As String ' Dim executionString As String executionString = "<BLP-1><HOME>ID " & isinCode & "<GO>" & _ "HP<GO><TABR>" & _ provider & "<TABR>" & _ "<TABR><TABR><TABR><TABR>" & _ "<TABR><TABR><TABR>" & _ period & quoteType & "<GO>" & _ "<PRINT>" ' createExecutionString = executionString End Function '
As you can see, the beef is inside createExecutionString function which creates executionString for DDEExecute function. When you open any Bloomberg function (say, SWPM<GO> for example), you can set up input values for all required argument fields by
1) clicking a field active with your mouse and then writing a value into a field
2) moving with keyboard TAB and then writing a value into a field
As you can see in createExecutionString function, it uses the latter approach by moving with keyboard TAB and then writing a value into a field. If you run that test program, you will see that it actually does all of this: moving with cursor in fields and writing a value. It's like that macro what you can record in your Bloomberg.
Anyway, I hope that you would find this post to be helpful and it could help you to solve your problem. Have a great start for June!
-Mike