From: Daniel Merk Date: 2007-10-29T21:43:29+09:00 Subject: win32ole type casting possible? ------=_Part_11154_6121855.1193661808129 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello all, I have a problem when I try to automate an application using Rubys win32ole class. I'll try to explain my problem by some simplified sample code: oleObj = WIN32OLE.new( 'Some.COM.application' ) foo = oleObj.getFoo #foo is either of type FooA or FooB fooType = oleObj.getFooType getFooType returns either 'A' or 'B'. This determines the actual type of foo. In case fooType is 'A', foo is of type FooA and has different ole-methods than in case that fooType is 'B'. If I use C# to automate the COM application, this can easily be solved by a typecast of form: FooA foo = ( FooA )oleObj.getFoo(); //For the case that getFooType returns 'A' As far as I know Rubys typing concept makes such a cast impossible. My question therefore is: Does the win32ole class support a mechanism that allows to convert the type of foo? If not, does anybody see other ways of solving this problem? I already considered writing a Ruby extension in C and do the typecast there, but I am not a windows expert, and all the IDispatch stuff really caused me severe headaches. Thank you, best regards Daniel ------=_Part_11154_6121855.1193661808129--