OL2002: CommandBars Not Available from Application Object (292182)



The information in this article applies to:

  • Microsoft Outlook 2002

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:="ChangingButton", _
   Position:=msoBarTop, Temporary:=True)
				

REFERENCES

For additional information about available resources and answersto commonly asked questions about Microsoft Outlook solutions, click the article number below to view the article in the Microsoft Knowledge Base:

287530 OL2002: Questions About Custom Forms and Outlook Solutions


Modification Type:MinorLast Reviewed:3/1/2004
Keywords:kbprb KB292182