Article ID: 182394 - Last Review: March 1, 2004 - Revision: 1.2 OL98: How to Use Command Bars in Outlook SolutionsThis article was previously published under Q182394 On This PageSUMMARY
This article provides an overview of using the CommandBars collection and
CommandBar object in a Microsoft Outlook 98 solution. Common issues and
examples are also provided as a starting point for working with
CommandBars.
Topics covered include:
MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either
expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes
that you are familiar with the programming language being demonstrated and the
tools used to create and debug procedures. Microsoft support professionals can
help explain the functionality of a particular procedure, but they will not
modify these examples to provide added functionality or construct procedures to
meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites: Microsoft Certified Partners - https://partner.microsoft.com/global/30000104 (https://partner.microsoft.com/global/30000104) Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice (http://support.microsoft.com/gp/advisoryservice) For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site: http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS (http://support.microsoft.com/default.aspx?scid=fh;en-us;cntactms) OverviewIn Microsoft Office 97, menus and toolbars are combined into one collection called CommandBars. The CommandBars collection is a shared Office component and is not directly part of the Outlook 98 object model.Microsoft Office applications such as Microsoft Word or Microsoft Excel support Visual Basic for Applications code that runs at the "application level." This means that the object models and programming environments in those applications are designed to allow a developer to create a programming solution that encompasses the functionality of the entire application. On the other hand, Visual Basic Scripting Edition (VBScript) code in Outlook 98 is stored and runs within individual forms or items. Outlook 98 does not support the concept of application-level Visual Basic code.
NOTE: You can use the C/C++ programming language to develop a Microsoft
Exchange Extension that is compatible with Microsoft Outlook 98. This is
the only type of custom application-level code that Outlook supports.
For more information on creating Exchange Extensions for use with Microsoft Outlook 98, see the whitepaper "Microsoft Outlook and Exchange Extensions" available on the Microsoft Developer Network Library: http://premium.microsoft.com/msdn/library
(http://premium.microsoft.com/msdn/library)
While Outlook 98 allows you to customize CommandBars through the user
interface and by using the CommandBars objects, you cannot have a menu
option or toolbar button at the application level that runs custom VBScript
code. Since the Outlook 98 object model is focused on items and VBScript
code within forms at the "item level," there is no direct association
between an application-level toolbar or menu command and the VBScript code
that runs at the item level. Note that you also cannot programmatically
assign a built-in Outlook command to a custom menu or toolbar.
You can use VBScript code within an item to modify the CommandBars of the item itself. However, Microsoft does not recommend this approach since it causes two undesirable side effects:
The CommandBars objects can be used, however, to execute an Outlook command that is available on the toolbars or menus. Typically these commands are application-level in nature and therefore not available in Outlook's object model. For example, you can execute the Tools Synchronize command to force Outlook to synchronize folders. Note, however, that menu commands often change with newer versions of the appication, so using this approach in a solution greatly increases the chances that your solution may not function correctly in the next version of Outlook. Understanding Explorers and InspectorsFrom a developer's point of view, the main window in Outlook (the "application window") is referred to as "Explorer" and the form windows are referred to as "inspectors." Both types of windows have command bars (including both menus and toolbars). When working with the Outlook command bars, it is always important to make sure you are working with the correct set of command bars.
Syntax for Referencing a Command BarUse the following simplified syntax in both Microsoft Visual Basic for Applications and Microsoft Visual Basic Scripting Edition (VBScript):VBScript Example to Execute an Outlook Command\You can use the following sample code with a Command Button on a contact form so that you can easily create a new letter for a contact:REFERENCES
For more information about using command bars in Outlook 98 solutions,
please see the following articles in the Microsoft Knowledge Base:
184791
(http://support.microsoft.com/kb/184791/EN-US/
)
OL98: How to Programmatically Synchronize Folders
186471
(http://support.microsoft.com/kb/186471/EN-US/
)
OL98: How to Programmatically Change Displayed Calendar Date
For more information about creating solutions with Microsoft Outlook 98,
please see the following articles in the Microsoft Knowledge Base:
180826
(http://support.microsoft.com/kb/180826/EN-US/
)
OL98: Resources for Custom Forms and Programming
182349
(http://support.microsoft.com/kb/182349/EN-US/
)
OL98: Questions About Custom Forms and Outlook Solutions
| Article Translations
|

Back to the top
