Excel process still running after program completion.

Chris chris.olekas at gmail.com
Tue Sep 11 11:45:58 EDT 2007


I have a python script that is driving Excel and using the win32com
module. However, upon program completion there's still an Excel.exe
process running in the background that I must terminate through Task
Manager. Reading up on other threads indicate that maybe I still have
some Excel objects referenced within my code. Is this why the process
doesn't terminate?

The related (I hope) parts of my code is here.

x1App = Dispatch("Excel.Application")
Book1 = x1App.Workbooks.Open(ExcelLogPath+"\\outputLog-template.xls")
x1App.Visible = 1
for sheets in Book1.Worksheets:
             if sheets.Name == file_name:
                      sheetExists = True
if sheetExists != True:
             activeSheet =
Book1.Worksheets.Add(After=Book1.Worksheets(1))
             activeSheet.Name = file_name
             testNum[file_name] = 0
Book1.Worksheets(file_name).Select()
Book1.ActiveSheet.Cells(1+(testNum[file_name]*20),1).Value = "Original
File Name"
Book1.ActiveSheet.Cells(2+(testNum[file_name]*20),1).Value =
file_name
Book1.ActiveSheet.Pictures().Insert(output).Select()
Book1.SaveAs(Filename=path)
x1App.ActiveWorkbook.Close(SaveChanges=0)
x1App.Quit()
del x1App
del Book1
del activeSheet

What am I missing?




More information about the Python-list mailing list