Sam,

> When I'm done with it, I want to close it and unload
> it from memory.  The right procedure is
>
> xl.quit
> xl = nil
> GC.start
>
> I want to make a function for the 3 steps.
>
> def quit_excel(xl)
>   xl.quit
>   xl = nil
>   GC.start
> end
>
> When I call it, I do
>
> quit_excel(xl) #don't work as expected
>
> As you know, the argument is call-by-value and even
> if I set nil to xl, the outer reference is still
> referencing Excel.  So GC won't collect it.

    One simple solution would be to keep the reference to x1 in an
array, then when you are done with it, simply delete the reference from
the array.  You will still have a reference to the array, but not to the
object itself.

    Of course, a better solution would be to encapsulate the reference
inside an object and have the object take care of creating and deleting
the reference.

    I hope this helps.

    - Warren Brown