I open several different workbooks (excel xlsx format) in COM, and mess with them. As the program progresses I wish to close one specific workbook but keep the rest open.
You can also try to use the following code:
excel = Dispatch("Excel.Application")
excel.Visible = False
workbook = excel.Workbooks.Open(fileName)
# with saving
excel.DisplayAlerts = False
if saveAs:
excel.ActiveWorkbook.SaveAs(fullFileNameToSave)
else:
excel.ActiveWorkbook.Save()
excel.Quit()
#without saving
map(lambda book: book.Close(False), excel.Workbooks)
excel.Quit()