Vamsi Krishna wrote:
> Hi,
> 
>  i'm trying to get the list of menubars in the excel using ruby
> i can able to get the menubars count but unable to get the list of menu
> bars.
> 
> my idea is to get the list of menubars and click on a perticular menu
> bar item.
> 
> my code is:
> 
> require "win32ole"
> excel=WIN32OLE.new("Excel.Application")
> excel.visible=true
> workbook = excel.Workbooks.Add
> excel.DisplayAlerts = false
> puts excel.MenuBars.ole_get_methods
> puts excel.MenuBars.count(* Here i can get the count.)
> excel.Quit
> 
> 
> Thanks
> Vk.

The MenuBars collection is not intended for use through the API.

You'll want to access the Worksheet Menu Bar via the CommandBars 
collection:

menubar = excel.CommandBars("Worksheet Menu Bar")

The following simple example iterates over the "Worksheet Menu Bar" 
CommandBar and prints out the name of each top menu and its menu items:

menubar.Controls.each do |menu|
  puts("MENU: #{menu.Caption}")
  menu.Controls.each do |control|
    puts("\t#{control.Caption}")
  end
end

I hope that helps. I can perhaps provide more detail later.

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