I have a Python code, it opens Excel, but the Excel close command does not work!(python 3.9, windows 10).
code:
def geeks():
p = subprocess.Popen(r"test.xlsx", shell=True)
while subprocess is not None:
os.kill(p.pid, signal.SIGTERM)
time.sleep(2)
geeks()
error:
os.kill(p.pid, signal.SIGTERM)
PermissionError: [WinError 5] Access is denied
I have been looking for the appropriate code for several days, but I can not find it.
What should I change in the code?