I'm trying to replace my VBA code(s) with python (3.6) and I cannot figure out how to start Excel (2016-64) with SAP Analysis for Excel from Python. Below is the code I'm using.
import win32com.client as w32
f_path = "example.xlsm"
xl = w32.gencache.EnsureDispatch("Excel.Application")
wb = xl.Workbooks.Open(os.path.abspath(f_path))
xl.Visible = 1
xl.WindowState = w32.constants.xlMaximized
With this method Excel will open however the Analysis add-in (.vsto) does not load. The things I've tried so far:
- Set the LoadBehaviour to 3 in regedit for the add-in (so it starts automatically)
- Try to launch the add-in with python in shell
- Include a macro within the Excel file that starts the add-in
If I start the file manually then the add-in loads properly. If I use the last two method then a new Excel instance will be started with the add-in while the file I was trying to use will not have the add-in loaded. What I found interesting that if I start Excel (without the add-in) and - by using VBA - I start the add-in (with the shell lib) then it loads properly.
Did anyone else had this issue before?