Pat Kitchener

Morning all,

I want to use Outlookspy to produce a complete list of control id'd for Outlook 2003 and Outlook 2007.

I have not got a clue how to do this, could any of you good natured techies please tell me how to go about doing this.

Please send me intructions by email as well as posting to pat.kitchener@conwy.gov.uk

Many thanks in anticipation opf your help


Pat



Re: Visual Studio Tools for Office OutlookSpy and Control ID's

Ji Zhou – MSFT

Hi,

You can use the following codes to list the CommandBar and CommandBarControls’s ID, Name property, via Outlook Add In or Outlook automation. Just loop through the collection and write it out to a text file.

Code Block

//Create a new txt file to record controls' list

StreamWriter sw = System.IO.File.CreateText(@"C:\Outlook Insepctor Command Bar Control List.txt");

//loop through Outlook ActiveInspector CommandBars to get all CommandBars

foreach (Office.CommandBar cb in app.ActiveInspector().CommandBars)

{

sw.WriteLine(cb.Name);

//loop through each CommandBar's Controls collection to get all controls

foreach (Office.CommandBarControl cbc in cb.Controls)

{

sw.WriteLine("\t" + cbc.Caption + "\t" + cbc.Id.ToString());

}

}

sw.Close();

Code Block

//Create a new txt file to record controls' list

StreamWriter sw = System.IO.File.CreateText(@"C:\Outlook Explorer Command Bar Control List.txt");

//loop through Outlook ActiveExplorer CommandBars to get all CommandBars

foreach (Office.CommandBar cb in app.ActiveExplorer().CommandBars)

{

sw.WriteLine(cb.Name);

//loop through each CommandBar's Controls collection to get all controls

foreach (Office.CommandBarControl cbc in cb.Controls)

{

sw.WriteLine("\t" + cbc.Caption + "\t" + cbc.Id.ToString());

}

}

sw.Close();

Hope it helps!

Thanks

Ji