I know this question has been asked when using VB directly, but I am having trouble terminating a process. I'm using the jruby version of win32ole and ruby 1.9. My current code is something like this:
begin
excel = WIN32OLE::connect('excel.Application')
rescue
excel = WIN32OLE::new('excel.Application')
end
excel.Visible = 1
workbook = excel.Workbooks.Open("path to some doc")
ws = workbook.Worksheets(1)
ws.Select
cell_content = ws.Cells(4,4).Value
puts("#{cell_content}")
workbook.Close
cell_content = nil
ws = nil
workbook = nil
excel.ole_free
excel = nil
GC.start
I'm trying to simply open excel, get a value and terminate. But when I look up task manager, I still see the EXCEL.exe running. Due to the begin-rescue it should also open an existing exe but every time I run it, it starts a new process. Once the script stops I manually close excel but I have also tried using excel.Close. Do I need to be calling the ruby equivalent of Marshal.releaseComObject? I don't have a lot of VB experience and I'm pretty new to ruby so I'm sorry if this is a dumb question, but thanks in advance!
Edit: I have also tried using excel.quit and excel.Quit, sorry I forgot to mention that. Neither seem to be working.
Edit 2: I'm running on rubymine and using windows xp, using gem: jruby-win32ole
Edit 3: Code properly terminate process on another computer, so possibly a problem with versions? Worked on jruby 1.5.6, process hangs on 1.6.5.1