From: Masaki Suketa Date: 2002-08-05T21:08:49+09:00 Subject: Re: win32ole and excel In message "Re: win32ole and excel" on 02/08/05, "MikkelFJ" writes: > mdm = WIN32OLE.new('MDM.Document.2') > mdm.Save ('testfile.mdd') (snip) > C:\test\w32\win32ole\sample>ruby test.rb > thialona > test.rb:6:in `method_missing': Save (WIN32OLERuntimeError) > OLE error code:80070057 in > > HRESULT error code:0x80020009 > Undtagelse opstod > from test.rb:6 > > The Com error is partly in danish: "Undtagelse opstod" which translates to > "an exception occurred". Althoug the error says "method missing" this isn't > true. If I change the Save to use two parameters I get a different error; FYI, The "method_missing" is because of the trick of Win32OLE. The mdm is WIN32OLE object and mdm does not have 'Save' method. mdm.methods.include?('Save') # ==> false So, WIN32OLE#method_missing is called and method_missing invoke 'Save' OLE method. > [id(0x00000022), helpstring("method Save")] > HRESULT Save([in, optional] VARIANT destination); Hmm, what happen when you omit optional argument? mdm.Save Unfortunately, WIN32OLE can not handle VARIANT type argument correctly. For example, AppendChunk of SQLServer (ADODB.Connection) accept one VARIANT type argument. But, to use AppendChunk from Win32OLE, you must use _invoke as following. obj._invoke(0x00000453, [data.unpack('C*')], [VT_ARRAY|VT_UI1]) So, How about mdm._invoke(0x00000022, ['testfile.mdd'], [VT_VARIANT]) or specify correct type directly. data = 'testfile.mdd' mdm._invoke(0x0000022, [convert_correct_type(data)], [???]) Regards, Masaki Suketa