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.