On 2022-02-09 12:45, Christian Gollwitzer wrote:
Am 09.02.22 um 08:46 schrieb NArshad:
When I enter data using Tkinter form in an Excel file when the excel file is 
closed there is no error but when I enter data using Tkinter form when the 
excel is already open following error comes:

PermissionError: [Errno 13] Permission denied: 'Abc.xlsx'



What to do to correct this error? I have already searched on google search many 
times but no solution was found.

It's impossible. Excel locks the file deliberately when it is open, so
that you can't overwrite it from a different program. Otherwise, the
file could become inconsistent.

It's the same the other way too; you can't open the file in Excel while Python has it open.

The correct way to handle it in the GUI is to tell the user via a
message box that the file is open and can't be written.

An alternative to writing the file directly would be that you remote
control Excel; I think it provides a DDE API:
https://support.microsoft.com/en-us/office/dde-function-79e8b21c-2054-4b48-9ceb-d2cf38dc17f9

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to