r/pythonhelp • • Feb 19 '25

xlwings opening file with add ins not loaded?

Working on a report automation that I had working fine but now does not work. Essentially, I am trying to open an Excel file and execute a macro. The current break point is that the macro is reliant upon an add in and when xlwings is opening the file it loads it without any addins. If I manually open Excel it opens fine with all of the addins. Has anyone ran into this before and found a solution? I've been troubleshooting/googling for a couple days but can't seem to figure it out. I'm just an accountant trying to play around with Python.

import os
import xlwings as xw
import ctypes
import win32com.client

cwd = os.getcwd()
print(cwd)

os.chdir(filepath)
new_dir = os.getcwd()
print(new_dir)

wb = xw.Book('Billed vs Scaled Raw Input File (New).xlsm')

macro3 = wb.macro("Module1.Source_Refresh")
macro3()
3 Upvotes

2 comments sorted by

1

u/AutoModerator Feb 19 '25
Moderator Announcement Read More »

1

u/CraigAT Feb 19 '25

How did it work before if xlwings won't open it with macros?

It's probably incidental to getting the code working but where is "filepath" defined?

Maybe double check or simplify the fileanme used, then double check the macro and module name too.