# COM Interop Problem

**URL:** <https://www.ruby-forum.com/t/com-interop-problem/183703>\
**Category:** IronRuby\
**Created:** [February 18, 2010, 9:51pm UTC](https://www.ruby-forum.com/t/com-interop-problem/183703 "2010-02-18T21:51:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![semmons99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@semmons99](https://www.ruby-forum.com/u/semmons99)\
**Post date:** [February 18, 2010, 9:51pm UTC](https://www.ruby-forum.com/t/com-interop-problem/183703/1 "2010-02-18T21:51:35Z")

</div>

Anytime I invoke a method on a COM object with one or more arguments,  
I get the following error:  
Could not convert argument 0 for call to Open. (ArgumentError)

What’s preplexing is the argument number is always the last argument,  
so if there are four arguments, the error will be on argument 3. Here  
is an example script that gives the error above:

def new\_com\_object(prog\_id)  
System::Activator.CreateInstance(System::Type.GetTypeFromProgID(prog\_id))  
end

xls = new\_com\_object(‘Excel.Application’)  
xls.Visible = true  
xls.Workbooks.Open(‘c:\Book1.xls’)

---

<div class="post-metadata">

**Author:** ![semmons99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f1d935/32.png) [@semmons99](https://www.ruby-forum.com/u/semmons99)\
**Post date:** [February 19, 2010, 4:01pm UTC](https://www.ruby-forum.com/t/com-interop-problem/183703/2 "2010-02-19T16:01:31Z")

</div>

On Thu, Feb 18, 2010 at 3:42 PM, Shane E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> end
> 
> xls = new\_com\_object(‘Excel.Application’)  
> xls.Visible = true  
> xls.Workbooks.Open(‘c:\Book1.xls’)
> 
> –  
> Shane E.

I figured it out, needed to to String#to\_clr\_string on every argument.
