Pyrevit custom toolbar for Revit 2025

Hello everyone,

We recently migrated to Revit 2025, all good with the latest pyrevit versions but we have an incompatibility with a custom toolbar. When we press the pushbutton it instantly throws’ the below error message. I have tried to edit the script to update it to a newer excel version to fix the Com object error but it looks like I am running in circles as one error leads to another. Did anyone had anything similar? The toolbars runs on python scripts only, nothing extra.

Or should we create a new toolbar from scratch for Revit 2025 + ?

Any tip or idea is highly appreciated.

have you used an AI tool. I can speak to Gemini - make sure to tell it the version of Revit and PyRevit and give the script and the error screenshot. Have fun! The possibilities are endless!

I tried only the copilot that comes as standard with our devices but I will give it a try with Gemini too.

a sample of the code could help guess work from actual human being.

What is the other software com object your are calling in your script?

Thank you for replying, Jean-Marc!

It seems that excel is the only object called.

The code part indicated by the error is:

try:

    excel = Marshal.GetActiveObject("Excel.Application")

except:

    excel = Excel.ApplicationClass()



excel.Visible = True

excel.DisplayAlerts = False



workbook = None

for wb in excel.Workbooks:

    if (wb.Fullname).lower() == excelPath.lower():

        workbook = wb

        break



if workbook is None:

    workbook = excel.Workbooks.Open(excelPath)

take a look at this one: pyRevit/extensions/pyRevitTools.extension/pyRevit.tab/Modify.panel/edit3.stack/Edit.pulldown/XLS Import.pushbutton/script.py at develop · pyrevitlabs/pyRevit · GitHub

try using the xlrd module
But it would depend on your version of Excel as well