From: Wang Dong Date: 2007-03-30T01:00:07+09:00 Subject: Re: excel is not closed in runtime using excel.Quit() On Mar 28, 8:28 pm, Masaki Suketa wrote: > Hello, > > In message "Re: excel is not closed in runtime using excel.Quit()" > on 07/03/28, Ruhul Amin writes: > > > Dear Dave, > > Thx for ur responce. This is my working code.I can not understand how > > can I use the single Excel instance for different files. > > Try the following style. > Create single Excel instance out of read_excel method, and > call excel.quit out of read_excel method. > And, pass the single Excel instance to read_excel method > as a argument. > > def read_excel(excel, file_name) > destination_file_name=file_name > begin > # You should not call WIN32OLE.new('excel.Application') in > # read_excel method. > # excel = WIN32OLE::new('excel.Application') > workbook = excel.Workbooks.Open("#{curdir} > .... > rescue > # You should not call excel.quit > # excel.quit in read_excel method. > end > end > > excel = WIN32OLE.new('excel.Application') > read_excel(excel, file_name) # 100 times call > excel.quit > > Regards Usually, I use %x{tskill excel} for finall clean.