Hello,
I can’t get rid of Excel, if I have ever called it,
even with such a simple script:
---------- code starts --------------
require ‘win32ole’
def puts_win32ole_objects
res = []
ObjectSpace.each_object do |o|
res << o if o.is_a? WIN32OLE
end
puts res.inspect
end
puts_win32ole_objects # --> empty
xl = WIN32OLE.new(‘Excel.Application’)
puts_win32ole_objects # --> one object
xl.Quit
xl = nil
GC.start # anything else I could do???
puts_win32ole_objects # --> the object is still there
sleep 5
And also the Excel process remains running in Windows.
Btw, even after the xl.Quit, the object remains fully functional,
so I could call o.Visible, o.Workbooks.Open(…) etc., it o were
the object (retrieved from ObjectSpace).
When the Ruby process is terminated (after sleep), the
Excel process will also terminate.
So, what’s the proper way to handle this?
I’ve found the WIN32OLE.ole_free method, but they say
that it is for debugging only.
Thanks for your help
Sven