Search code examples
pythonexcelcomribbonxlwings

Is there a way to use the commands/features in the Ribbon of an excel sheet through Python xlwings?


To avoid any confusion, I would like to point out that I am not trying to install the xlwings addin for Excel and have the xlwings tab appear in the ribbon.

Rather I am creating a python program in which I would like to access and use the other add-in features located in the Ribbon atop Excel windows. I have been using xlwings to manipulate excel through python and am wondering if this, or any other libraries, are capable of what I would like to do.


Solution

  • No, you cannot do that with xlwings. You can however do exactly that with PyXLL https://www.pyxll.com.

    Here's the relevant section from the docs: https://www.pyxll.com/docs/userguide/ribbon.html.

    Unlike xlwings, PyXLL is an Excel add-in that embeds Python into Excel allowing you to create fully featured Excel add-ins in Python, including your own ribbon controls.

    You can read more about the differences between the two packages here https://support.pyxll.com/hc/en-gb/articles/360042910613-What-is-the-difference-between-PyXLL-and-xlwings-