0

When I try and call any method on a COM Object that takes one or more arguments, I get the following error on the last argument:

Could not convert argument 0 for call to Open. (ArgumentError)

Everything works fine when calling a method that takes no arguments, or getting/setting a property. Here is the code that gives me 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')
4

1 回答 1

0

看起来我需要在调用方法时使用 String#to_clr_string 。现在 IronRuby.net 文档很无聊,所以很难弄清楚。

于 2010-02-19T14:14:13.680 回答