I have excel with the Bloomberg API ( which uses simple calls like =BDP(“MS equity”,”ask”) ). I also have a C# application that opens an excel file (through interop) that uses the Bloomberg API. I have read here that addins are not loaded when you load excel through interop. I have even tried using the code suggested there. However, that only seems to work for XLL and XLAM files and it looks like Bloomberg also uses DLL files which doesn’t get loaded. Is there any way to get all of these addins to be loaded through interop?
Share
I assume that, if you start excel manually the add-ins are loaded properly.
If so, you can get an Excel Interop Object with loaded BB-Addins by calling
Process p = Process.Start("excel.exe");and then using theAccessibleObjectFromWindowmethod to get the Interop Object.An example on how to do that can be found here.
Quick walkthrough
I decided to show the steps I went through to get an
Excel.Interop.Applicationinstance with loaded bloomberg add ins. Maybe someone looks at this and finds it useful, or knows where I missed something to get a more elegant solution.The simplest way doesn’t work
Run()will throw aCOMException:Loading AddIns by hand doesn’t work
But if start Excel by klicking on the Windows Taskbar, the AddIns are being loaded nicely… So I tried to start excel by starting the executable file “excel.exe”.
Using Process.Start(“excel.exe”) works!!
Starting excel using the
System.Diagnostics.Processclass loads the bloomberg AddIns. (I can see theBloomberg-RibbonTab.)Now all I need is the Interop-Object of that excel process. I can get it using the above example
My implementation of it
Now I can use the following line of code to get an
Excel.Interop.Applicationinstance with loaded bloomberg addins!I hope this spares someone the hours I wasted with this and if someone has a more elegant solution and wants to share it, it would be much appreciated.