Automating Ribbon/Nav Bar Menus for MS Office 2007/2010-like applications
I would like to ask if there's a way to automate/code selecting buttons from Ribbon/Nav Bar menus from a MS Office like application?
I am working on an application developed on using .Netv4 framework. I've also added .Net as an add-in to recognize its objects. It has detected usual .Net objects such as SwfButtons, SwfEdit, etc. However it recognizes Ribbon objects as SwfObjects; Also if the ribbon group contains 2 or more buttons, QTP 11 sees those as one SwfObject.
I also think that QTP recognizes objects with a regexpwnclass of WindowsForms10.Window.8.app.0.1555552_r22_ad as not SwfObjects.
Please advise any help on this or if a patch is needed to recognize the objects. Thank you very much in advance!
Are there any native object properties and values associated with these controls which can be helpful for automation?
Automating MS Office like application is tricky .. below is some sample code with which one can click on an option(button in this case) displayed in MSWord ribbon control ... not perfect code just created in hurry.. but should give you some idea on how your approach should be .. let know if it helped
'In word app .. i'm clicking on an item displayed on the ribbon ..
ItemToolTipToSelect = "&Numbering"
Set oShell = CreateObject("Wscript.Shell")
Set oWord = CreateObject("Word.Application")
Set od = oWord.Documents.Open("file path")
oword.Visible = True
Set oc = oWord.CommandBars.FindControls
flag2 = ""
For ctr = 1 To oc.Count - 1
str = oc.Item(ctr).Caption
'**** **** **** Trying to only access items in the following command bar **** **** ****
If Trim(str) = "&Styles and Formatting..." Then
flag = "f"
If flag = "f" Then
'**** if tooltip is = retreived tooltip then click the item, it can be any condition here ... ..
If oc.Item(ctr).TooltipText = ItemToolTipToSelect Then
'App Activate code
If instr(1,str,"...",1) > 0 and Trim(str) <> "&Styles and Formatting..." Then
Thanks for the help! However the application I'm testing right now can't be open thru CreateObject method. However, while looking thru the object's properties, I've seen that the Ribbon Bar's swftypename is DevComponents.DotNetbar.RibbonStrip. I think I found a way automating the Ribbon Strip. But that only solves one of my problems,
The application also contains an Office Button in which I couldn't somehow get its properties in ObjectSpy since its disappears once QTP is active. Have you tried automating this type:
Thank you for your huge help!