I have an Excel file which relies heavily on UDFs programmed in python (xlwings). It works just great on a PC where python is installed along with the add-in. The problem is I have to send the file to a bunch of people who don't even know what python is. Because of UDFs, a frozen executable is out of the question. So what I did:
Downloaded an embeddable python installation (Windows x86 embeddable zip file) from python.org, extracted it to the folder where the xlsm file is (in a separate folder named 'Python').
Downloaded get-pip.py from bootstrap.pypa.io, uncommented the line 'import site' in the file python36._pth, ran 'python get.pip.py'.
Downloaded pywin32 and comtypes wheels from Christoph Gohlke's great site, installed them with 'pip install [filename].whl'. Installed xlwings ('pip install xlwings'). The total size of this installation is 50Mb.
Created a new file with a xlwings module installed ('xlwings quickstart myproject --standalone'). Renamed the '_xlwings.conf' sheet to 'xlwings.conf', entered the following formula in the 'Interpreter' field:
=LEFT(CELL("filename";A1);FIND("[";CELL("filename";A1))-1) & "Python\pythonw.exe"It automatically calculates the correct path to the python interpreter wherever the file is opened.
Macros and UDFs seem to be working, but each time when I open the file all UDF formulas throw an 'ActiveX component can't create object' error. If I force a recalculation ([CTRL]-[ALT]-[SHIFT]-F9) everything starts working again, but I can't expect that my end users will know how to do this. Is there a trick to make UDFs work out of the box? Or maybe there's a more convenient way to distribute xlwings-powered Excel files?