Wang Dong
3/29/2007 3:57:00 PM
On Mar 28, 8:28 pm, Masaki Suketa <masaki.suk...@nifty.ne.jp> wrote:
> Hello,
>
> In message "Re: excel is not closed in runtime using excel.Quit()"
> on 07/03/28, Ruhul Amin <tuhin_cs...@yahoo.com> 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.