Using White to Automate Office 2007 Ribbon

May 13, 2008 at 2:56 PM
Edited May 13, 2008 at 2:59 PM
Hi,

I'm trying to use White to automate the Office 2007 Ribbon control, in the following example I've used UIA Verify (http://www.codeplex.com/UIAutomationVerify) to identify the properties on a button on the ribbon, specifically the 'Name' of the the 'Bold' button (which is 'Bold'). I then use the Get method on the WordMainWindow  to try and get hold of the button but it fails to populate the button and I get an object reference not set error when the bold.Click line is hit. Have you any suggestions for trying to automate the Office 2007 ribbon?

 

public Core.Application Word = null;
public Window WordMainWindow = null;

Word = LaunchApplication(Word,

@"C:\Program Files\Microsoft Office\Office12\Winword.exe");
WordMainWindow = Word.GetWindow(
"Document1 - Microsoft Word", InitializeOption.NoCache);

B
utton bold = WordMainWindow.Get<Button>(SearchCriteria.ByText("Bold"));
bold.Click();

Thanks,

James
 
 

Coordinator
May 15, 2008 at 12:58 PM
I have Office 2003, and I tried your code. It works fine.
Can you send me the output of WordMainWindow.LogStructure();
Jun 2, 2008 at 3:56 PM


viveksingh wrote:
I have Office 2003, and I tried your code. It works fine.
Can you send me the output of WordMainWindow.LogStructure();



Office 2003 has a very different interface to Office 2007; most importantly it doesn't have a ribbon and its this ribbon that I need to be able to automate. Can you try Office 2007?

If you can't get Office 2007 and aren't sure what I mean by ribbon then take a look at: http://en.wikipedia.org/wiki/Microsoft_Office_2007#Ribbon

I can provide you the output of WordMainWindow.LogStructure(); if you tell me where this gets output too,

Cheers,

James.

Coordinator
Jun 3, 2008 at 7:12 AM
You can configure log4net by looking at the configuration page on the wiki. When white runs it would send a message on output window about log4net if it is not configured.
If you do window.LogStructure() the output come out in the log file as well as system out.