Bernard K. wrote:
Use appl.Quit not appl.quit
make sure your workbooks are closed prior to quitting.
I use this code snippet to open the excel application
begin
excel = WIN32OLE.connect("excel.application")
rescue
excel = WIN32OLE.new(“excel.application”)
end
Thus I connect to a running Excel instance or start a new instance.
Hi Bernard.
Why use appl.Quit and not appl.quit? Observations have shown that they
both work just fine, and all of the Excel DOM collections, objects,
properties, methods and enumerations are handled in a case insensitive
manner. Is it to distinguish between possible future additions to the
script my programmers other than myself that might add a #quit method
and/or due to the #missing_method paradign that WIN32OLE uses? Doesn’t
using capital letters for method names go against the ruby syntax rules
for naming conventions? Is it a holdover from VBA? Does your
recommendation apply to the other Excel DOM methods, properties (etc) as
well?
I’ve worked out a workflow that does not involve using quit (see above),
but I am closing my workbooks. Thanks.
Good idea on the “connect”.
And, finally, to learn the methods of a class, like WIN32OLE, I would
typically go interactive (IRB or such) and issue a
WIN32OLE.methods - Object.methods
to get a list of the methods specific to WIN32OLE. I see connect, and a
few others:
[“codepage”, “codepage=”, “connect”, “const_load”, “ole_free”,
“ole_reference_count”, “ole_show_help”]
Where does one get doc on these methods? And, obviously missing here is
#new, but that’s due to my (probably flawed) process of getting method
names, since one can Object.new too.
Todd