From: Ar Vicco Date: 2011-02-23T08:21:34+09:00 Subject: Re: WIN32OLE Question on Accessing an Enum OK, I'm in a similar fix with an OLE method that expects an enum... I'm driving a proprietary COM object using WIN32OLE, and one of the classes has a PROPERTYPUT method 'type' that expects enum of type TRequestType, defined in the same typelib. In the documentation, this method is described like this: Property: type [in/out] enum TRequestType When I run olegen script on this typelib, this is what comes out of it: class DataStream ... def type=(arg0) @dispatch._setproperty(4, [arg0], [VT_DISPATCH]) end ... end module TRequestType include WIN32OLE::VARIANT attr_reader :lastargs RT_LOCAL = 0 RT_COMBINED_SNAPSHOT = 1 RT_COMBINED_DYNAMIC = 2 RT_REMOTE_SNAPSHOT = 3 RT_REMOVE_DELETED = 4 RT_REMOTE_ONLINE = 8 end OLE method stub seems to expect an OLE object, but I cannot instantiate TRequestType enum... It has CLSID, but trying WIN32OLE.new with this CLSID gives: ----- WIN32OLERuntimeError: failed to create WIN32OLE object from `{508266CF-A83D-46FE-95B3-E8F892950E61}' When I try to give this method Fixnum (say 1) instead of enum, I get: ----- TypeError: not valid value WIN32OLE documentation does not mention how to work with OLE enums. I tried to fiddle with WIN32OLE_VARIANT, but was unable to fugure out how to use it properly... So, essentially I have no idea how to make this enum and pass it into method that expects it. :( Any help pushing me in the right direction is greatly appreciated... At the very minimum, I need to understand in what direction to dig, and now I'm at a total loss... Help? -- Posted via http://www.ruby-forum.com/.