Microsoft KB Archive/292182

= OL2002: CommandBars Not Available from Application Object =

Article ID: 292182

Article Last Modified on 3/1/2004

-

APPLIES TO


 * Microsoft Outlook 2002 Standard Edition

-



This article was previously published under Q292182





SYMPTOMS
You use programming code to automate the Microsoft Office CommandBars object model, but the code generates an error when used with Outlook.



CAUSE
Unlike other Office programs, the CommandBars object is not available as a property of the Outlook.Application object. Therefore, errors will occur if you use code that is designed for other Office programs.



RESOLUTION
Outlook implements CommandBars in both folder windows and form windows, so the CommandBars object is accessed through the Explorer and Inspector objects, respectively. Modify your code to include one of these objects, as appropriate.



MORE INFORMATION
Most CommandBar code examples that are available on the http://msdn.microsoft.com Web site and in other Microsoft Office documentation were designed for the other Office programs.

The following Visual Basic for Applications code segment illustrates how to reference the CommandBars object in Outlook:

Set myExplorer = Application.ActiveExplorer Set myBar = myExplorer.CommandBars.Add(Name:=&quot;ChangingButton&quot;, _  Position:=msoBarTop, Temporary:=True)

