Thomas B. wrote:
>> Now there's one more problem - the list doesn't contain strings, but 
> WIN32OLE_METHOD objects. I do not actually know how to handle this, but 
> this is how you can check if Visible= is among the methods of the 
> object:
> excel.ole_put_methods.find{|m| m.name=="Visible"}
> The above line returns nil iff excel does not respond to Visible=.
> 
> TPR.

Hi Thomas,

I find the method "Visible" but not"Visible=" here but the 
respond_to?("Visible") still return false. I don't know how to explain 
it.

Li

C:\Users\Alex>irb
irb(main):001:0> require 'win32ole'
=> true
irb(main):002:0>
irb(main):003:0* excel=WIN32OLE.new("excel.application")
=> #<WIN32OLE:0x398d638>
irb(main):004:0>
irb(main):005:0*
irb(main):006:0* puts "first method"
first method
=> nil
irb(main):007:0> excel.ole_get_methods.each do |e|
irb(main):008:1*   if "#{e}"=="Visible"
irb(main):009:2>      puts "find Visible"
irb(main):010:2>      elsif "#{e}"=="Visible="
irb(main):011:2>        puts "find Visible="
irb(main):012:2>        else
irb(main):013:2*          #puts "no method"
irb(main):014:2*          end
irb(main):015:1> end
find Visible
=> [Application, ...MANY METHODS HERE... HighQualityModeForGraphics]
irb(main):016:0>
irb(main):017:0* puts "second methods"
second methods
=> nil
irb(main):018:0> excel.ole_put_methods.each do |e|
irb(main):019:1*   if "#{e}"=="Visible"
irb(main):020:2>      puts "find Visible"
irb(main):021:2>      elsif "#{e}"=="Visible="
irb(main):022:2>        puts "find Visible="
irb(main):023:2>        else
irb(main):024:2*          #puts "no method"
irb(main):025:2*          end
irb(main):026:1>
irb(main):027:1* end
find Visible
=> [ActivePrinter,...MANY METHODS HERE... 
LargeOperationCellThousandCount,HighQualityModeForGraphics]
irb(main):028:0>
irb(main):029:0* puts excel.respond_to?("Visible")
false
=> nil
irb(main):030:0>


-- 
Posted via http://www.ruby-forum.com/.