How to prevent xlwings from disabling other add-ins (SQL Spreads)

23 Views Asked by At

I have the SQL Spreads add-on for work unrelated to this code.

When I attempt to run my xlwings python script, it always crashes when attempting to open an excel workbook:

wb_output = xw.Book(output_file_path, update_links=False)

with this error code:

Exception has occurred: com_error
(-2146959355, 'Server execution failed', None, None)

xlwings error

When this occurs, it also disables the SQL Spreads add-in. When I run the code a second time, it functions correctly and is able to work without interruption. However, I have to re-enable my SQL Spreads extension every time after running the script.

SQL Spreads disabled add-in

I have been unable to avoid the first crash and disabling of SQL Spreads. SQL Spreads requires a Microsoft account login when opened, so my suspicion is that xlwings gets timed out when SQL Spreads requests the login info.

SQL Spreads login prompt

How can I make xlwings not disable my other add-in, and not crash the first time I run the python script?

1

There are 1 best solutions below

0
Hibbert On

After working on this some more, I have found a work around.

  1. Open a SQL Spreads excel file
  2. Login to your account via the prompt
  3. Leave the SQL Spreads file open while the xlwings code runs

This prevents the login popup from disrupting the xlwings code, as it has already been satisfied. I have noticed this workaround is not perfect, and sometimes results in SQL Spreads being disabled, but it is successful most of the time.