I want to run a vba macro that has IRibbonControl as a parameter using Python win32com.
For example, my vba sub is looks like below
Public Sub test(control As IRibbonControl)
from win32com.client import DispatchEx
xl = DispatchEx('Excel.Application')
xl.Application.Run("test", some magic needs here)
You would need an object on python-side that implements
IRibbonControl, and pass that as parameter back to Excel.
The only way I can imagine this makes sense (but I have an open mind) is if you implement a COM add-in (https://support.microsoft.com/en-us/kb/291392) as
IDTExensibility2. Then you will be called the
OnConnection method (in your python COM server), which gives you the Excel application object.
From there, you could very likely obtain a reference to the ribbon control.
I must admit that I did so far not manage to get any python COM Excel add-in to work myself, though I tried.
Or can you not better obtain the
IRibbonControl from the excel application from within the sub, and remove it from the argument list?