Xlwings Excel and Windows Task Scheduler issues

Question:

I have a python script that runs perfectly when I manually run the python script. It opens a shared excel file, adds data to the bottom of the sheet in real time with other users in the file, auto saves and closes.
However, when I schedule this task with windows task scheduler on windows 10, it opens the file, but does not show other users in the excel file, nor will it auto save.

any ideas on how to get it to open excel properly and update in real time?

wb = xw.Book('Pending Tracker.xlsx')
ws = wb.sheets['Pendings']
val = ws.range('A1').end('down').offset(row_offset=1, column_offset=0).options(index=False, 
   header=False).value = comparison_df
time.sleep(20)
wb.app.quit()

Photo of Task Scheduler Setup

Asked By: blakevandermeer

||

Answers:

I found the fix to make it work. Hopefully someone else that is having issues with an Excel file that is shared Via OneDrive with multiple users will find this useful. In Task Scheduler, it needed to be run as Windows Server 2003 without Highest Privelages and now XLWings will open the file with other people in it, add information to the bottom of the spreadsheet, auto save and close without kicking other users out.

Answered By: blakevandermeer

I’ve had a similar problem:
I had a Python program with the xlwings library and I created a .bat file.
When I launched it by hand it worked perfectly, but with Window 10 Scheduler I received an error "(-2147024891, ‘Access denied.’, None, None)".
I carried out the automatic correction of the Excel file which can be done by going to Excel > File > Info > Verify document.

My problem was that the Windows Scheduler didn’t accept comments in the .xlsm file