I am working with an excel file that outputs into a new excel file called 'outfile'. How this works is that there is a button on my first excel file. When the button is pressed it runs an optimization problem in python and opens the new outfile. Everytime someone has to run the program this outfile needs to be closed. The only way I could find to avoid that is to open the file and then close it. However, when I run the program through excel I get a warning that the file is already open.
How do I ignore the warning?
This is my python code:
x1 = Dispatch('Excel.Application')
wbk = x1.Workbooks.Close('C:/Users/MChoudhary/Desktop/a/outfile.xlsx')
wbk.Close(True)
...optimization stuff
wb1.save('C:/Users/MChoudhary/Desktop/a/outfile.xlsx')
os.startfile('C:/Users/MChoudhary/Desktop/a/outfile.xlsx')
I essentially want the file to be closed when the program is run again instead of manually have to close it.