The information in this article applies to:
SUMMARY
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.
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 the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.asp 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. http://premium.microsoft.com/msdn/libraryWhile 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):
The following syntax may not work in all cases:
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:
REFERENCESFor more information about using command bars in Outlook 98 solutions, please see the following articles in the Microsoft Knowledge Base: Q184791 OL98: How to Programmatically Synchronize Folders Q186471 OL98: How to Programmatically Change Displayed Calendar DateFor more information about creating solutions with Microsoft Outlook 98, please see the following articles in the Microsoft Knowledge Base: Q180826OL98: Resources for Custom Forms and Programming Q182349 OL98: Questions About Custom Forms and Outlook Solutions Additional query words: OutSol OutSol98
Keywords : kbdta kbdtacode OffVBA |
Last Reviewed: November 13, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |