Search code examples
pythonexcelpywin32win32com

Pull List of COM Add-ins Available in Excel w/ Python Library


I'm trying to build out a process to refresh a series of excel documents on a monthly basis. One part of this process will require refreshing data from an Excel Add-In (In my case this is an add-in called SmartView).

I can't find any info on how to pull a list of add-ins accessible to the pywin32 module. Is there a way to access and iterate through a list of Add-Ins?

Here's what I know works if you know the name of the Add-In:

import win32com.client as win32

xl = win32.gencache.EnsureDispatch('Excel.Application')

helloWorldAddIn = xl.COMAddIns("HelloWorld") # HelloWorld is the name of my AddIn.

Solution

  • The Application.COMAddIns is actually a collection of COMAddIn objects, so you can iterate over the list of available add-ins like:

    import win32com.client as win32
    
    xl = win32.gencache.EnsureDispatch('Excel.Application')
    
    for addin in xl.COMAddIns:
        print(addin.description)