From: "list. rb" Date: 2007-07-09T03:24:12+09:00 Subject: Re: win32ole: application.quit() leave process running ------=_Part_157822_8264522.1183919054614 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Interesting. If you exit the ruby/IRB instance, the EXCEL process will close, but not until then. irb(main):040:0> xlapp = WIN32OLE.new('excel.application') => # irb(main):041:0> objWMIService = WIN32OLE.connect ("winmgmts:\\\\.\\root\\cimv2" => # irb(main):042:0> colProcessList = objWMIService.ExecQuery("Select * from Win32_process") => # irb(main):043:0> colProcessList.each do |objProcess| irb(main):044:1* puts ['Name', 'ProcessId'].collect {|i| objProcess.send(i)}.join(",") if objProcess.Name == 'EXCEL.EXE' irb(main):045:1> end EXCEL.EXE,3644 => nil irb(main):046:0> xlapp.Quit => nil irb(main):050:0> colProcessList = objWMIService.ExecQuery("Select * from Win32_process") => # irb(main):051:0> colProcessList.each do |objProcess| irb(main):052:1* puts ['Name', 'ProcessId'].collect {|i| objProcess.send(i)}.join(",") if objProcess.Name == 'EXCEL.EXE' irb(main):053:1> end EXCEL.EXE,3644 => nil On 7/8/07, Todd Burch wrote: > > I'm working a lot with Excel lately in Win XP Pro. It seems EXCEL.EXE > continues to run after my script is finished. > > I have: > > xlapp = WIN32OLE.new('excel.application') > .... > xlapp.activeworkbook.close ; > xlapp.quit() ; > > I was expecting the .quit() method to end the EXCEL.EXE process. > However, Task Manger tells me it is still running. Matter of fact, > after running the script 10 times, there are 10 instances of EXCEL.EXE > running. > > My logic is simple enough that I know I am issuing the .quit(). I've > tried the .ole_free method as well, and no joy, even though it returns > "true". I've also tried: > > xlapp.sendkeys("%fx") ; # works, but EXCEL.EXE is still running > > Ideas? > > Thanks, Todd > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_157822_8264522.1183919054614--