I looked at google for a solution based on python, but did not find any...
My python script is trying to edit an xlsx that might be opened by another user from MS excel. If I try to overwrite the .xlsx file or the ~$*.xlsx file, I get a winError 32: 'process cannot access the file because it is being used by another process'
My problem is that users around me use MS excel to look at this output... And MS excel always lock the files that are open, by default.
It there a way to 'steal' the access from the other users. (As they are not editing it anyway).
I cannot not change the user permission (I think) as I am not admin of the files.
I am using windows 10.
Thanks for your advices.
cheers.
There really is no way around this - it is Excel preventing any other process on the system from obtaining write access.
If it were running on the same machine, you could consider connecting to the running Excel instance and getting it to close and reopen the document after opening it for writing yourself, but in your example it would likely be opened by someone on another machine.
The only solution here is to instruct your users to open the worksheet as read-only, which is an option every version of Excel allows, in which case you might be able to open it for writing. Whether that will allow you to update it while they are looking at it, is doubtful - you likely may want to look into connecting to an Excel sheet on OneDrive or SharePoint (or Teams etc. that use SharePoint as a back-end).