Connecting Tech Pros Worldwide Help | Site Map

Closing an excel application

  #1  
Old July 8th, 2009, 04:49 PM
Newbie
 
Join Date: Sep 2007
Location: Buffalo, NY
Posts: 25
Hi All....

I'm using python 2.4, Win XP Pro v.2002 sp3, and I use pyscripter 1.9.9.2 as my editor.

I have written code to open an existing excel file and grab some data. The problem I am having is closing down the excel application. Here some "bits" of the code I am using:

Expand|Select|Wrap|Line Numbers
  1. xlApp = Dispatch("Excel.Application")
  2.  
  3. xlApp.Workbooks.Open(Filename = path+fname)
I am closing the workbook by doing the following:

Expand|Select|Wrap|Line Numbers
  1. xlApp.Workbooks.Close()
I am trying to quit the excel application by doing the following:

Expand|Select|Wrap|Line Numbers
  1. xlApp.quit()
The problem is when I check the windows Task Manager, the EXCEL.EXE is still present. From all I have read, this is the correct way to close the workbook and exit the excel application.

Can anyone tell me what I might be doing wrong.

Thanks in advance.

Silgd1
  #2  
Old July 9th, 2009, 04:48 PM
Newbie
 
Join Date: Sep 2007
Location: Buffalo, NY
Posts: 25

re: Closing an excel application


I found out that you must do the following:

Expand|Select|Wrap|Line Numbers
  1. xlApp.Visible = 0
  2. del xlApp
you must make x1App.Visible=0 before you use del x1App, otherwise EXCEL.EXE remains in memory.
  #3  
Old July 10th, 2009, 12:01 PM
bvdet's Avatar
Moderator
 
Join Date: Oct 2006
Location: Nashville, TN
Posts: 1,545

re: Closing an excel application


Thanks for updating us with the solution. I am only somewhat familiar with win32com. I usually interface with Excel using CSV files.

-BV
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
closing an excel worksheet in vb .net Bernie Yaeger answers 0 November 20th, 2005 06:29 AM
Closing an excel workbook fires Workbook_BeforeClose Winshent answers 0 November 18th, 2005 09:56 PM
Excel application.quit leaves instance of Excel running ChrisBowringGG@gmail.com answers 8 November 17th, 2005 09:47 AM
closing excel application federico answers 4 July 18th, 2005 05:05 AM