how to Get the list of MenuBars in excel using ruby

V

Vamsi Krishna

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.
 
D

David Mullet

Vamsi said:
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
 
V

Vamsi Krishna

Thank you David, its working.
can you please send some links or additional information for clicking
the menubars and menus in the Excel using ruby.


Thanks
Vk.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top