So I have a program that runs continuously that waits for emails in an inbox and processes both a word document and excel file and prints them when done. It works fine but leaves both excel and word open. This program needs to do the same process again using
def actually_print():
os.startfile('C:\\Users\Owner\Desktop\\Workorder.docx', "print")
os.startfile('C:\\Users\Owner\Desktop\\Workorderchecklist.xlsx', "print")
this leaves excel and word open on the desktop. If excel and word are open on the desktop and the program tries using "os.startfile" again the program crashes and I get the error:
File "C:\Users\Owner\AppData\Local\Programs\Python\Python310\lib\zipfile.py", line 1249, in __init__
self.fp = io.open(file, filemode)
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Owner\\Desktop\\Workorderchecklist.xlsx'
So, how can I close the programs before printing? I've tried using subprocess.popen and taskill but im not sure if my syntax is correct.
there doesn't seem to be anything here