Search code examples
pythonvbaconsolestdoutxlwings

Can I Have xlwings Display Console Output?


Is it possible for xlwings to pop up a console while running a script from VBA and show stdout?

I know xlwings writes the stdout to a logfile which is useful, but I'd like to give users some updates while they are waiting for their calculation to finish. The debugger kind of does this but seems like overkill.


Solution

  • If you are using UDFs, then there is a simple possibility: By default xlwings uses the pythonw interpreter. Just change it to python and the console window will pop up.

    For RunPython you'd need to hack the source code of the addin currently, see here. Basically search for WindowStyle and set it to 1 instead of 0. It should be easy to make this a config at some point.

    Update: On Windows, this is now possible via the Show Console setting in the add-in since version 0.20.8.