Working with the Application Object

[Previous] [Next]

The objects described in the following sections are used in the user interface of your applications.

Explorer Object

The Explorer object in Outlook corresponds to an Outlook window in which items in a folder are displayed. An example of an Explorer window is shown in Figure C-2. The Explorer object and its children objects are considered user interface objects. If you need to modify the user interface elements in an Outlook application, you need to use either the Explorer or the Inspector objects. The Inspector object is discussed later in this supplement.

click to view at full size.

Figure C-2 An Outlook window, which is considered an Explorer object in the Outlook object model.

Explorer Object Properties

The following section describes these two key properties of the Explorer object and how you can take advantage of them in your application.

CommandBars Property

The CommandBars property of the Explorer object returns a collection of CommandBar objects that represent the menus and toolbars of the Explorer object. As you will see later in this supplement, the Inspector object also has a CommandBars property, since the Outlook window (Explorer) and an Outlook item (Inspector) may have different menus available to them. The following code snippet shows you how to use the FindControl method on the CommandBars collection to find the Choose Form command and execute it. In the Inspector code sample of the CommandBar property, you will find code taken from the Account Tracking application that shows you how to send a letter to a specific contact using a built-in Outlook command of the contact form.

     Sub CommandButton1_Click         Application.ActiveExplorer.CommandBars. _             FindControl(,1910).Execute         'Or you can use this syntax         Application.ActiveExplorer.CommandBars.Item("Menu Bar"). _             Controls("Actions").Controls("Choose Form…").Execute     End Sub 

You should use only the second version of the syntax when you know for certain that the command you want is on one of the menus. If the command is not on the menu, Outlook will return an error to you. The first version of the syntax will work even if the command is not on any of the menus of the user, because you are using a unique identifier to find the command you want to execute.

NOTE
To obtain a list of all the unique identifiers for the Outlook commands, you can create a simple program to print these out. They are also listed in the Microsoft Knowledgebase article Q173604, "OL97: How to Use Command Bars in Outlook Solutions."

CurrentFolder Property

The CurrentFolder property allows you to find or set the current folder that is displayed in the Explorer object. By using this property, you can change the folder that the current user is viewing. The following example shows you how to display and set the CurrentFolder property:

    Sub CommandButton1_Click         msgbox Application.ActiveExplorer.CurrentFolder.Name         set oNS = Application.GetNameSpace("MAPI")         set oCalendar = oNS.GetDefaultFolder(9)         set Application.ActiveExplorer.CurrentFolder = oCalendar     End Sub 

Explorer Object Methods: Close and Display

There are only two methods that you can use with the Explorer object in Outlook: the Close method and the Display method. The Close method will close the Explorer without saving any changes. The Display method will display the Explorer object. The following code sample shows how to use both of these methods:

     Sub CommandButton1_Click         'Display the currently select Explorer         Application.ActiveExplorer.Display         Msgbox "Shutting down this explorer. . . "         Application.ActiveExplorer.Close     End Sub 



Programming Microsoft Outlook and Microsoft Exchange
Programming Microsoft Outlook and Microsoft Exchange, Second Edition (DV-MPS Programming)
ISBN: 0735610193
EAN: 2147483647
Year: 2000
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net