Serving the Quantitative Finance Community

 
User avatar
bskilton81
Topic Author
Posts: 0
Joined: December 16th, 2004, 8:30 pm

Bloomberg DDE and VBA Macro

May 22nd, 2007, 3:12 pm

I have an Excel VBA Macro set to get data from another Excel file. The data in the other file relies on the Bloomberg DDE link. When I run the macro, the DDE links don't update on the other sheet. If I do it manually, they do. Anyone have any experience with this?
 
User avatar
bskilton81
Topic Author
Posts: 0
Joined: December 16th, 2004, 8:30 pm

Bloomberg DDE and VBA Macro

July 10th, 2007, 12:08 pm

Solved it. Solution is to use a macro to open the file, then in that macro us an application.ontime reference to start another macro. First macro ends, second macro starts. Second macro polls to see if sheet is updated using isnumeric() and application.min(). If sheet isn't updated, another application.ontime call, then macro closes. Macro re-opens and starts again. The closing of the macro each time enables other processes to kick off in between the macro runs.
 
User avatar
cemil

Bloomberg DDE and VBA Macro

July 10th, 2007, 12:24 pm

What is it this Excel VBA Macro ?is it possible to have a copy?thanks
 
User avatar
bskilton81
Topic Author
Posts: 0
Joined: December 16th, 2004, 8:30 pm

Bloomberg DDE and VBA Macro

July 10th, 2007, 2:45 pm

Works like this: Say you have a file called rates.xls with FX spots from bloomberg along the top. Call that range FXSpotsSay you want that data to go into in another file, update.xls.Make two macros, UpdMacro and openratesbook.First run openratesbook macro-------------------------------------------------------------------------------------------------------------------------------Sub openratesbook() Application.ScreenUpdating = False Application.Calculation = xlCalculationAutomatic Workbooks.Open Filename:="C:\rates.xls" Application.OnTime Now() + TimeValue("00:00:02"), "UpdMacro"'This ontime call will run UpdMacro in 2 seconds. In the meantime, the openratesbook macro ends.End Sub-------------------------------------------------------------------------------------------------------------------------------Sub UpdMacro()Application.ScreenUpdating = FalseWindows("Rates.xls").Activate If IsNumeric(application.min(Sheets("Sheet1").Range(FXSpots))) = False Then Windows("Update.xls").Activate Application.OnTime Now() + TimeValue("00:00:02"), "UpdMacro"'This ontime call kicks off updmacro again in 2 seconds. In the meantime, the current run of UpdMacro ends. In between the macros, the bbe links in 'the sheets are allowd to update. Else'If the data is updated correctly, copy it to the update.xls file and close the other file. Thing = Sheets("Sheet1").Range(FXSpots) Windows("Rates.xls").Close Application.Calculation = xlCalculationManual Windows("Update.xls").Activate Sheets("Sheet1").Range(DataRange) = Thing Application.ScreenUpdating = True End IfEnd Sub
Last edited by bskilton81 on July 9th, 2007, 10:00 pm, edited 1 time in total.
 
User avatar
cemil

Bloomberg DDE and VBA Macro

July 11th, 2007, 8:01 am

Thanks!Firstly, I thought that it is a macro to link 2 applications in 2 computers via DDE link.