Python win32com opens Excel with Bloomberg plugin

I am trying to automate the creation of an Excel 2007 spreadsheet that uses the Bloomberg plugin to lower real prices. The problem is that when I open Excel through win32com, the Bloomberg plugin does not load (so that all formulas end with "#NAME?" Errors).

Manually uninstalling and reinstalling the plugin works, but copying the VBA code from the recorded macro leads to the error "Runtime Error" 13: Type mismatch error. I can click the “Finish” button and everything works fine, but I want this to be fully automated.

My code is:

import win32com.client
xl = win32com.client.gencache.EnsureDispatch("Excel.Application")
xl.Visible = True
MainWorkBook = xl.Workbooks.Add(1)
xl.AddIns("Bloomberg Excel Tools").Installed = False
xl.AddIns("Bloomberg Excel Tools").Installed = True

Setting DisplayAlerts = False does not resolve the runtime error.

+3
1

bloomberg.xla - :

from win32com.client import DispatchEx
xl = DispatchEx('Excel.Application')
xl.Workbooks.Open('C:/blp/API/Office Tools/BloombergUI.xla')

. : http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.addin.aspx

+2

Source: https://habr.com/ru/post/1748598/


All Articles