What's New for Microsoft Outlook 2000 Developers

Extensive changes have been made to the Microsoft Outlook 2000 Visual Basic object model to support new and improved features in the application. Many objects, properties, methods, and events have been added, both to support new features and to extend the functionality of existing features.

New Feature Areas

The following topics provide conceptual information about features that are new in Outlook 2000.

  • Visual Basic for Applications Hosted by Outlook

  • Support for COM Add-ins

  • Application-Level Events

  • Additional Access to Explorer and Inspector

  • Additional Access to Attachments

  • Support for Contact Linking

  • Support for Custom Property Pages

New Language Elements

The following topics provide lists of language elements that are new in Outlook 2000.

  • New Objects

  • New Properties (by Object)

  • New Properties (Alphabetical)

  • New Methods (by Object)

  • New Methods (Alphabetical)

  • New Events (by Object)

  • New Events (Alphabetical)

New Features in Outlook 98

The following topic provides information about developer features and language elements that were new in Outlook 98.

What Was New for Microsoft Outlook 98 Developers


Understanding Outlook e-mail service options

Microsoft Outlook 2000 can be installed in one of three modes: Corporate Workgroup, Internet Mail Only, or No E-mail.

Corporate Workgroup mode is designed for use with Microsoft Exchange Server and provides a MAPI-based architecture. It uses profiles to configure how mail is transmitted and where it is stored. This mode is most commonly used in a corporate environment with Microsoft Exchange Server, which provides many of Outlook's collaborative capabilities, such as the Organizational Forms Library and public folders.

Note Some of the topics in this documentation apply only when Microsoft Outlook is used in conjunction with Microsoft Exchange Server, since that is the mode most commonly used to develop solutions based on Microsoft Outlook.

Internet Mail Only mode is used when Outlook is being used to connect to an Internet Service Provider (ISP) instead of to Microsoft Exchange Server.

No E-mail mode is similar to Internet Mail Only mode, but without e-mail capabilities.


 Design Outlook Workgroup Solutions

Design Outlook Workgroup Solutions

With Microsoft Outlook, you can create a variety of workgroup solutions and forms. You can create workgroup solutions by using custom views in a public folder,. You can also create simple forms with no programming involved or create advanced forms by using custom controls, properties, and VBScript. You can also use another Office program to create a form.

There are four basic approaches to creating Outlook solutions. You can use existing items, such as tasks or appointment items, put the items in a public folder, and assign a view to the folder. This method gives you an instant workgroup solution without writing any code. Another method is to modify an existing item, such as a contact or mail message, by adding additional pages and fields. With this method, you can extend the use of the item by adding the fields and pages you need without writing any code. To create advanced forms, you can use the Control Toolbox and VBScript to access properties, events, methods, and objects within Outlook. You can also use Office document forms, such as using Microsoft Excel to create an expense report.

What method do you want to use?

Create an instant workgroup solution using public folders

Extend the use of an Outlook item by adding additional fields and pages

Create custom forms by using VBScript

Create forms by using Office documents


Overview of a Typical Folder-based Solution

When used with Microsoft Exchange Server, Microsoft Outlook provides groupware capabilities that allow more than one person to work on the same data. Even without using these capabilities, however, you can still customize Outlook folders for your personal use or to create a solution that other people in your organization can use.

If you’re planning to build a groupware solution, you should consider first working with Outlook to develop a single-user solution. Since a groupware solution is often as simple as placing a custom form in a Microsoft Exchange public folder, learning the basics of building a folder-based personal forms solutions will be fully applicable to developing solutions in public folders.

Whether it’s in one of your personal folders or in a Microsoft Exchange public folder, putting together an Outlook solution typically involves the following steps:

  1. Decide which type of folder and/or form to customize. For more information, see Types of Forms in Outlook.

  2. Open a new form and customize it to suit your needs.

  3. Publish the form to the folder so that it’s available only for use in that folder.

  4. Set the custom form as the default form for the folder. This will ensure that when you create new items for use in this folder they’ll be based on the custom form you created.

  5. If you have any existing items in the folder, update these items so they will use the new form when they’re opened. For more information, see Change the Form Used by Existing Items in a Folder.

Note If you plan to use a custom form in a folder, you should create the custom form before creating any items based on the form. This will ensure that all the items in the folder use the same set of fields.

If you need to update the form after having created some items in the folder, follow these steps:

  1. Open a new, blank item based on your custom form.

  2. Update the form to suit your needs.

  3. Republish the form to the folder using the same name.


Using views to create a solution

Although custom forms provide a powerful way to work with data in a folder, you can also customize Microsoft Outlook to a great extent simply by creating a view that suits your needs. In some cases, depending on how you want to work with Outlook, you can use a custom view instead of a custom form to enter and modify data.

Entering data in a view is usually done be selecting one of the Outlook table views, wherein each row contains one item in the folder and each column represents a field associated with an item. You can select the fields that Outlook displays, and you can also enter or change the contents of fields directly in the table view. This allows you to quickly modify items, even those that contain custom fields.

To allow field editing in a view

  1. Click View, point to Current View, then click Customize Current View.

  2. Click Other Settings.

  3. Select Allow in-cell editing.

Editing items in a table view lets you keep track of custom data, view multiple items at the same time, enter data into an item without having to open the item, and avoid having to create a custom form.


 Change the default view in a folder

Change the default view in a folder

  1. If the Folder List is not visible, click the View menu, and then click Folder List.

  2. Right-click the folder you want to change the default view for.

  3. Click Properties on the shortcut menu.

  4. Click the Administration tab.

    5. Note If the Administration tab does not appear, you don't have owner permission.

  5. In the Initial view on folder box, enter the view that you want to appear each time the folder is opened. The Normal view displays the default Microsoft Outlook view for the type of items in the folder.

To change the default view for a public folder, you must have owner permission for the folder, and there must be at least one custom view defined that is visible to everyone for the folder.


Show only the custom views in a folder

  1. On the View menu, select Current View, click Define Views.

  2. Select the Only show views created for this folder check box.


Set permissions in a folder

If you are the owner of a public folder, you can set permissions in the folder to give users the ability to perform certain functions. By adding the user names, distribution list names, or public folder names to the Name box on the Permissions page, you can determine who can:

  • Create items

  • Read items

  • Create subfolders

  • Edit items

  • Delete items

You can also determine who is the Folder owner and the Folder contact and to whom the Folder is visible.

To set permissions:

  1. In the Folder list, right-click the public folder for which you want to set permissions and then click Properties on the shortcut menu.

    Note The Properties tab is only available if the folder is a public folder.

  2. Click the Permissions page.

  3. Click the Add button to add a user name to the list. Choose a name from the Address Book and click OK.

  4. Select the user's name in the Name box for whom you want to alter permissions.

  5. In the Roles box, choose the role for this user. The permissions check boxes will automatically revert to the default values for this role.

  6. If you want to define a custom role, check the permissions check boxes that you require for this user. The value in the Roles box will change to "Custom".

  7. When you have set the Roles for all the users, click OK on the Properties page.

Note To remove a name, select the name and click Remove. You can remove any name from the Name box except Default.


 Create a custom field

Create a custom field

In Outlook, you can create different types of custom fields based on the data type that you select.

For information about the data types that you can use, click here

For information about standard formats that you can use with data types, click

  • If you want to enter and show information about an item, you can create a simple field with one data type. For example, if you want to enter a date, you can create a Date/Time field.

  • If you want to show more than one field in a column in a table (or in a row in a card), you can create a combination field with a Combination data type. You can either show all the selected fields joined together in a column or show only the first non-empty field. This is useful if you want to optimize the use of screen space in a view.

  • If you want to show the results of calculations on standard fields or fields you create, you can create a formula field. For information about the standard fields for items in Outlook, click [image] . For information about the functions you can use, click [image] .

What do you want to do?

Create a simple field for a folder

Create a combination field for a folder

Create a formula field for a folder


 About Outlook forms

About Outlook forms

A form is an easy way to distribute and collect information electronically. For example, a form can be available for anyone to order supplies or post information in a public folder. Microsoft Outlook provides built-in forms such as the New Message form to compose messages and the New Contact form to enter information for a contact. If you have sent an e-mail message or created an appointment, you have used a form. Every Outlook item is based on a form.

You use the Outlook Forms design environment to create custom forms either from an item (based on a built-in form) or from an Office file. Use a built-in form to leverage functionality from the item associated with it — for example, to include automatic name checking in a custom form, create it from a form based on a mail message. To modify a form, you can add and remove fields, controls, options, and tabs. You can use an Office file to incorporate functionality from another Office program, such as Microsoft Excel or Word, into a custom form. A form can be saved as a file (for use as a template or in another program) or in a forms library (to make the form available to others).

Developers can extend forms with ActiveX controls and put World Wide Web pages right on their forms by using Internet Control Pack controls. Forms can be programmed by using VBScript.

You cannot use Outlook Forms in Visual Basic and Microsoft Exchange, although you can use forms created with the Microsoft Exchange Forms Designer in Outlook.


How Outlook forms and items work together

Microsoft Outlook stores its information in the form of individual items in a folder. An Outlook item is similar to a record in a database in that it consists of a group of fields that store information pertaining to the specific item.

Outlook displays the contents of an item in one of two ways: either through a view in an explorer window, or through a form in an inspector window. A form usually provides a more complete display of the information and lets the user interact with the contents of the item in more ways. In a sense, a form is the principal user interface for an item. Outlook provides one or more standard forms for each type of item (mail message, contact, and so on). You can create customized versions of these forms to change the way Outlook displays items. You can display additional pages that are usually hidden, and you can add controls to those pages. Typically, these controls are bound to fields in the item so that the user can view and edit the contents of those fields. In some cases, you can also customize the default pages of a form.

Every item contains a Message Class field; this field contains the name of the form that Outlook provides to view and edit the item. For example, a contact item will have a default message class of IPM.Contact. If you create a custom form called Customer, the Message Class field of items using that form will contain IPM.Contact.Customer. The message class of all Outlook items always begins with IPM. The second part of the message class denotes the type of Outlook form that the form is based on. The third portion of the message class is present only if the form is a customized version of a standard Outlook form.


Types of forms in Outlook

To create a custom form in Microsoft Outlook, you always begin by choosing one of the Outlook default forms. In most cases, the type of form you want to customize is determined by what type of solution you are creating. The following table lists the types of forms and how they would typically be used.

Form | Description
Contact | Use to keep track of information about a person or organization.
Distribution List | Use to create a lists of contacts and e-mail addresses that can be used as a single e-mail address.
Task | Use to track information about a task that needs to be accomplished.
Mail Message | Use to send information to someone in a specific format, or to provide a means for them to enter data so that they can send it somewhere.
Post | Use to facilitate a threaded conversation in a Microsoft Exchange public folder, or use for other purposes, such as posting file attachments to a folder.
Appointment | Use to represent a meeting or scheduled event.
Journal Entry | Use to log information about another item or an event.
Office Form | Use when most of the customization is being done in an Office application, such as a Microsoft Word document or a Microsoft Excel workbook.

Following are some things to consider when deciding which type of form to use:

  • What is the nature of the solutions you are creating? If the form will be sent, then a mail message would be appropriate. If the solution will be used to track information in a folder, then a post, contact, task, or appointment form would be more appropriate.

  • Which form most closely provides the needed functionality? The default Outlook forms may provide much of the functionality, so you should choose the one that would require the least customization.

  • Which standard fields are available for the form? Each Outlook form has its own set of standard fields to keep track of information for those types of items. You should consider using the form whose fields most closely match you needs.

  • Which pages of the form are customizable? Some pages on Outlook forms are not customizable, although you can hide them if you want.


 Change the default form for a folder

Change the default form for a folder

This procedure requires owner permission for a public folder.

  1. Right-click the folder for which you want to specify the default form, and then click Properties on the shortcut menu.

  2. In the When posting to this folder, use box, click the form that you want others to use.

Tip To copy, install, delete, and update forms in this folder, click Manage on the Forms tab. You can also specify available forms in a public folder by selecting an option under the Allow these forms in this folder box.

Learn how to change the form for existing items in a folder


Change the form used by existing items in a folder

In some cases you may need to change the form associated with items that are already in a folder. This is often necessary after importing items, or if you create a custom form after you have already created items based on a standard Microsoft Outlook form.

The Message Class field cannot be directly changed using the Outlook user interface, but you can use VBScript, Visual Basic, or Visual Basic for Applications to change the Message Class field.

The following Automation code can be used as a basis for developing your own solution. This code assumes that the name of the new form is MyForm. It will change all contacts in your default contacts folder so that they will use MyForm.

Sub ChangeMessageClass()
Set olApp = New Outlook.Application
Set olNS = olApp.GetNameSpace("MAPI")
Set ContactsFolder = _
    olNS.GetDefaultFolder(olFolderContacts)
Set ContactItems = ContactsFolder.Items
For Each Itm in ContactItems
   If Itm.MessageClass <> "IPM.Contact.MyForm" Then
      Itm.MessageClass = "IPM.Contact.MyForm"
      Itm.Save
   End If
Next
End Sub

Note If you want to use a folder other than a default folder, use the Folders collection object to refer to any folder that is available in your Folder List.


 Create an Outlook form

Create an Outlook form

Note All custom forms must be based on existing Outlook forms. If you do not wish to use the default form functionality provided by Outlook, you can hide all of the default form pages and use only the extra blank pages to create a complete custom form.

For information about hiding form pages, click here

For more information about selecting the Outlook item on which to base your custom form, click here

For information about how to create a form using an Office document, click here

To begin designing an Outlook form:

  1. Open an Outlook item. This can be accomplished by various methods. For example, to open a new mail message item, you can:
    • Click on the New Mail Message icon to open a mail message.

    • Click on the arrow beside the New Mail Message icon and click on Mail Message.

    • Select New on the File menu and click on Mail Message.

    • Select New Mail Message on the Actions menu.

    • Double-click anywhere in an empty area of the Inbox view pane.
  2. When you have the new form opened, on the Tools menu of the form, select Forms and click Design This Form. You may also click Design Form and choose to design a different form.

  3. Add the fields, controls, and code that you want to your new form.


 Customize pages on a form

Customize pages on a form

In general, you can customize up to five pages on a form. For e-mail messages and posts, you can customize a sixth page, the Message page; and for contacts, you can customize the General page.

With the form in design mode:

  1. Click the page that you want to customize.

  2. From the Field Chooser, drag a field to the page. Outlook automatically sizes the field for you.

    If the field that you want doesn't appear in the Field Chooser, click a different field set in the box at the top of the Field Chooser.

  3. To align, size, or remove fields, right-click the field, and then select the options that you want on the shortcut menu.

  4. Add and remove controls.

Tips

  • To create fields, click New in the Field Chooser. Type a name for the field in the Name box, and then select a field type and format. Fields support calculated expressions, validation formulas, and field formatting. How to create fields,

  • If you drag a field or control to a hidden page, the page automatically shows on the form at run time.


 Create forms by using Office documents

Create forms by using Office documents

Office documents can be used as forms in Outlook although you will not be able to create custom form pages.

To open an Office document as a form:

  1. Point to New on the File menu, and then click Office Document.

  2. Double-click the type of document you want to use.

  3. In the message box, select Post the document in this folder if you want to open the document as a post item or select Send the document to someone if you want to open the document as a mail item.

You can design and layout any type of form that meets your needs using the features of the program. For example, you can create a simple custom form, in which users simply fill in empty cells, using Microsoft Excel. Or you can use all the macros and Visual Basic controls in the program to create a more advanced custom form. You can set the form properties and actions, or publish the form to a forms library by selecting Forms on the Tools menu and clicking Publish Form. Once you open an Office document as a form, you must use the program Help command on the Help menu (for example, if you open a Word document, click Microsoft Word Help on the Help menu).


 Create a form from an Office file

Create a form from an Office file

This procedure requires that you are in an Outlook folder for items or a public folder, not a file folder.

  1. On the File menu, point to New, and then click Office Document.

  2. Double-click the icon for the type of file you want to start.

  3. To create a form that you can post to a public or private folder and that contains only a Document page, click Post the document in this folder.

    To create a form that you can send and that contains Document, Message, and Options pages, click Send the document to someone.

  4. On the Tools menu, select Forms and click Design This form.

  5. Hide or show pages on the form.

    How?

  6. Set properties on the (Properties) page.

    How?

  7. Create custom actions, such as responses for the form.

    How?

  8. Save and distribute the form.

    How?

  9. Test the form.

    How?


 Create custom forms by using Visual Basic Scripting Edition

Create custom forms by using VBScript

Microsoft VBScript is a subset of Visual Basic for Applications. You can use VBScript to create procedures that control Microsoft Outlook folders, objects, items, and properties. VBScript in Outlook requires a special object syntax that has some differences from referencing objects in Visual Basic for Applications.

Learn about the Outlook object model.

See a visual representation of the Outlook object model hierarchy.

You can choose the Outlook item on which to base your custom form. Learn about choosing an item.

You can extend Outlook forms by using custom controls from the Control Toolbox. Outlook forms can use most of the properties and methods that come with the controls. Since controls cannot store values, to store the value you need to bind the control to an Outlook field.

Learn about binding.

The Outlook object browser displays the classes, properties, methods, events, and constants available from the Outlook object library. The object browser lets you view and use objects in the Microsoft Script Editor and obtain information about the syntax for using the object.

Learn about viewing and using the object browser.

The Microsoft Script Debugger provides you with a comprehensive debugging environment for testing and correcting errors in the VBScript code for your forms.

Learn about the Script Debugger.


 Extend the use of an Outlook item by adding additional fields and pages

Extend the use of an Outlook item by adding additional fields and pages

In this approach, you take a standard Outlook item, such as a contact, mail message, task request, or meeting request and add fields and extra pages.

To see a sample of how an existing item can be modified, click [image] .

Note All custom forms must be based on existing Outlook forms. If you do not wish to use the default form functionality provided by Outlook, you can hide all of the default form pages and use only the extra blank pages to create a complete custom form. For information about hiding form pages, click here

  1. Open the item on which you want to base the form. For example, if you want your form to organize and collect information about a person or organization, open a contact. In the contact, select Forms on the Tools menu and click Design This Form. This opens the item in design mode.

    For more information about selecting an Outlook item on which to base your custom form, click here

  2. Set attributes for the form. In design mode, you add attributes such as a caption, password, or description on the Properties page. The Actions page lists default Reply forms. You can add your own custom Reply forms to the Actions page as well as change several aspects of how the default Reply forms work. For more information about how to set form attributes, click here

  3. Design the form by moving, removing, and adding fields and pages in the form. All the fields in the form and all the fields you add from the Field Chooser retain their built-in properties and functionality. For procedures on designing form pages, see Creating Forms under Solutions with Forms, Public Folders, and Views on the Help Contents tab.

  4. Test and publish your form. You can instantly see how your form looks; just open your new form in run mode by clicking Run This Form on the Form menu on the form. You can publish your form to your Personal Forms Library or to a folder to test it, and then publish the form to a public folder or to the Organization Forms Library so other users can use it. For more information about how to save a form to a forms library, click here


 Use the Field Chooser

Use the Field Chooser

Although you can add a control to a form and then bind the control to a field, it is usually more effective to use the Field Chooser. The Field Chooser lets you add a control and bind it to a field in a single step. Also, in many cases, the built-in control provided by the Field Chooser has special features and capabilities that cannot be duplicated by binding a field to a standard control.

Outlook displays the Field Chooser whenever you open a form in design mode.


 How to open a form

How to open a form

You can open custom forms that you create in Outlook. How you open a custom form depends on where you saved it.

To open a form | Do this
In the Folder Forms Library | Select the folder in which you saved the form and click the Actions menu Select the form that you want and click to open it.
In the Organizational Forms Library | In the File menu, select New and click Choose Form. (In the Choose Form dialog box, click Organizational Forms Library in the Look In box if necessary.)
In the Personal Forms Library | In the File menu, select New and click Choose Form. (In the Choose Form dialog box, click Personal Forms Library in the Look In box if necessary.)
Saved as an Outlook template | In the File menu, select New and click Choose Form. (In the Choose Form dialog box, click User Templates in File System in the Look In box if necessary.)
Saved as a file | On the Tools menu, click Find. In the Find pane, click Advanced Find.In the Look for box, click Files (Outlook/Exchange) and then type the name of the file in the Named box.
In the Standard Forms Library | In the File menu, select New and click Choose Form. (In the Choose Form dialog box, click Standard Forms Library in the Look In box if necessary.)


 How to edit a form

How to edit a form

  1. Open the form.

    How?

  2. On the Tools menu, select Forms and click Design This Form to switch to the design mode of the page.

  3. Make your changes.

  4. Save the form.

    How?


 Create custom actions for a form

Create custom actions for a form

With the form in design mode:

  1. Click the (Actions) page.

  2. Click New.

  3. Select the options that you want.

    For Help on an option, click the question mark [image] and then click the option.

Notes

  • You can specify whether you want an action to appear as a command on both the Actions menu of the form and the Form Design toolbar, or just on the item menu.

  • You can use actions to open other forms, even forms of a different type. For example, you can create a message form with an action that opens a contact form.

  • You can also use actions to create new items. For example, you can create a message form with an action that creates a new contact. The new item is created in the open folder, not in the Contacts folder.


Overview of Appointment Forms

The default pages of an appointment form are not customizable. Because these pages provide much of the Microsoft Outlook appointment scheduling functionality, it’s recommended that you do not hide these pages, but add additional functionality to a new page on the form.

After creating a custom appointment form, the default starting date and time for new appointments will no longer be set to the current date and time rounded to the next half hour. You can use the following sample VBScript code to restore this functionality:

Function Item_Open()
   CurrentDayTime = Now()
   CurrentDay = Int(CurrentDayTime)
   CurrentTime = CurrentDayTime - CurrentDay
   ' Round time to next half-hour
   NewTime = (Int(CurrentTime * 48) + 1) / 48
   Item.Start = CurrentDay + NewTime
End Function


 Overview of Contact Forms

Overview of Contact Forms

The General page of a contact form can be modified, but the other default pages cannot be customized. You can hide these pages and create new pages on the form if you choose. Learn about using contact item selector fields.

The following steps demonstrate how to create a new Categories button on a form. You can also use these steps to create a button that will display the Check Full Name or Check Address dialog boxes.

To create a Categories button on a contact form

  1. In design mode, use the Control Toolbox to add a CommandButton control to the page.

  2. Right-click the control, click Properties, and then click the Display tab.

  3. In the Name box, type cmdCategories.

  4. In the Caption box, type Categories.

  5. On the Valuetab, click Choose Field, point to All Contact fields, click Categories, and then click OK.

  6. To test the button, on the Form menu, click Run This Form. When the form is displayed in run mode, click the Categories button.

Although the Categories field is grouped under All Contact fields, it can be used on all types of forms because all forms have a Categories field. The Check Full Name and Check Address dialog boxes will only work on a contact form, however.

Note On the General page, you cannot modify the address, phone and e-mail "selector" lists that contain the names of standard Microsoft Outlook fields. Also, the FileAs list offers two choices if only a contact's first and last name have been entered, or five choices if a company name has also been entered. This list of choices cannot be modified.


 Using contact item selector fields

Using contact item selector fields

You can customize a contact form using specially bound controls that display dialog boxes that let users change fields in the item.

Most of these controls are available directly from the Field Chooser. The following lists these controls.

Address Selector | Address Selected
E-mail Selector | E-mail Selected
Phone x Selector | Phone x Selected

To use these fields on a contact form page, open the form in design mode and then use the Field Chooser to drag the field onto the page. This will automatically create the appropriate controls and labels on the page.

You can also bind a standard control button to one of three special contact dialog boxes:

  • Categories

  • Check Address

  • Check Name

To bind a contact-item dialog box to a button

  1. In design mode, drag a command button from the Control Toolbox to a page on the form.

  2. Right-click the command button, click Properties, and then click Value.

  3. Click Choose Field, point to All Contact fields, and then click the name of the dialog box you want to bind the button to.

Note You can also use the same method to bind the Categories dialog box to a button on the form of any item except a mail message. However, the Categories dialog box is listed only under All contact fields, regardless of the type of form being designed.


Overview of Distribution List Forms

The default pages of distribution list form are not customizable. Because these pages provide much of the Microsoft Outlook distribution list functionality, it’s recommended that you do not hide these pages, but add additional functionality to a new page on the form.


Overview of Journal Forms

The default page of the journal form cannot be modified, but you can hide this page and create new pages on the form if you choose.

Note The list of Entry Type entries cannot be customized.


Overview of Mail Forms

All pages of a mail form are customizable.

Like post forms, mail forms have separate Compose and Read pages. When a user opens a new mail message, the form is displayed in Compose mode and pages are displayed so that the user can fill out the form to be sent. When the recipient opens the item, the form is displayed in Read mode, and a different set of pages and controls can be used to display the data in the fields. When designing a mail message form, you can choose to disable the separate Read and Compose pages so that the form is identical at all times. If you use separate pages, you can often copy and paste the controls from the one set of pages to the other.

Learn about making separate Compose and Read pages

If you are customizing a mail form for use in an organization that is using Microsoft Exchange Server, the form should be published in the Organizational Forms Library. If you do this, then you can clear the Send form definition with item check box on the form's Properties page so that only the field data is transmitted when the item is sent. This will greatly reduce network traffic and also make updating the form much easier in the future because each client will be using the shared form that is published on the server.

When designing a mail form, it’s important to consider which type of message format the form should be in. Choices include Microsoft Rich Text, HTML, plain text, or Microsoft Word. Careful consideration should be given to what versions of Microsoft Outlook or Word potential recipients will be using. To programmatically set HTML in a mail form, see HTMLBody Property. To programmatically access the Word object model to manipulate a Word mail message, see WordEditor Property.

Note Some of the properties and objects related to mail formats may behave differently depending on whether Outlook was running in Corporate Workgroup mode or Internet Mail Only mode.


 Make separate compose and read versions for a form

Make separate compose and read versions for a form

You can create and edit separate compose and read versions for each page of a form. The compose version is what the sender sees — for example, what you see when you create a message. The read version is what the recipient sees — for example, what you see when you read your mail.

With the form in design mode:

  1. To create or edit the compose page, click Edit Compose Page on the Form menu.

    To create or edit the read page, click Edit Read Page on the Form menu.

  2. Customize pages on the form.

    How?

Note You can quickly switch between the two versions by clicking the Edit Compose Page and Edit Read Page buttons on the Form Design toolbar. If these buttons are not available, you set compose and read versions to be the same. To have separate compose and read versions, click Separate Read Layout on the Form menu.


Overview of Post Forms

Like mail forms, all post form pages are customizable, and post forms also have separate Compose and Read pages that you can modify.

Learn about making separate Compose and Read pages

A folder containing posts is usually grouped by the Conversation field to keep related topic together. The Conversation field, also known as the ConversationTopic property in the Microsoft Outlook object model, is set based on the Subject field of a new post in the folder. All replies to this item will inherit the Conversation field from the parent item.


Overview of Task Forms

The default pages of a task form are not customizable. However, you can hide these pages and create new pages on the form if you choose.

When tasks are used in a personal folder, you can assign tasks to other people. However, when task items are placed in a Microsoft Exchange public folder, they cannot be assigned. Instead, the Owner field can be modified to reflect who currently owns the task. It may be advantageous to create a custom view so that the tasks are grouped by their owner.


 Create a reply form

Create a reply form

When you create a Message form, you often want users to send a reply by using a reply form.

An action automatically opens a reply form, typically when a user clicks Reply, Forward, or another command on the form. For example, an action can create a Forward button, that, when selected by the user, opens a Forward form for the user to fill in and send to reply to your message. You can specify that the form use standard Reply and Forward headers, and you can even add prefix text, such as RE: to the Subject field of your custom reply form.

You can use the default reply forms included with Outlook (these are the forms listed on the Actions page), or you can disable any of these forms and create a custom reply form. The custom reply forms that you create are listed on the Actions page in design mode in the form.

You can create custom buttons and menu commands and specify what happens when the user chooses them. You can also create a button or menu command that opens a task, a Calendar item, or even a note.

You can send information without opening a reply form by pre-addressing a custom reply form to go to a specific e-mail address or to a public folder.

What do you want to do?

Create a custom reply form

Add a custom button or menu command to start a reply form

Open a task, Calendar item, or note from a custom form

Use standard Reply and Forward headers on a form

Automatically insert text into the Subject field of a reply form

Specify whether a form prompts the user, opens, or is sent

Pre-address a reply form to a public folder or an e-mail address


 About the form name and message class

About the form name and message class

The message class is an internal identifier used by Outlook and Microsoft Exchange to locate and activate a form.

The MessageClass property corresponds to the MAPI property PR_MESSAGE_CLASS. This class property determines which receiving folder the message should be routed to and which form should be activated to view the message.

In the Publish Form As dialog box, when you type a name in the Display name field, you will notice that the Form name field reflects the display name by default. You can leave the form name to be the same as the display name or you can change the form name. The display name will be the caption at the top of your form. The display name will also be used to construct the name under which your form will be published. When you publish your form, the display name will be listed in the Choose Form dialog box.

Outlook automatically constructs a message class for the form by preceding the form name with IPM. For instance, if you publish a mail message form that you want to name "MyForm", in the Display name field, type: This is my Form. In the Form name field, type: MyForm. At the bottom of the dialog box, Outlook will display the message class for your new form as: IPM.Note.MyForm.

When you search in the Choose Form dialog box, you will see "This is my Form" displayed in the list. If you select it, the Display name field at the bottom of the dialog box will display, "This is my Form" and the Form name field will display, "MyForm".

A message class, which is generated automatically by Outlook from the form name, is assigned to the form. When a form with that message class is selected, Outlook loads and displays an instance of that form. Outlook will use the message class, IPM.Note.MyForm, to locate the form with the display name, "This is my Form".

For more information about item types and message classes, click here


 Item types and message classes

Item types and message classes

The type of an item is defined by its Type property. The message class for an item is defined by its MessageClass property.

Message class ID | Item type is used to
Ipm.Activity | Create journal entries.
Ipm.Appointment | Create appointments.
Ipm.Contact | Create contacts.
Ipm.DistList | Create distribution lists
Ipm.Document | Create documents.
Ipm.OLE.Class | Create the exception item of a recurrence series.
Ipm | If the specified form cannot be found.
Ipm.Note | Create e-mail messages.
Ipm.Note.IMC.Notification | Create a report from the Internet Mail Connect (the Exchange Server gateway to the Internet).
Ipm.Note.Rules.Oof.Template.Microsoft | Show out-of-office templates.
Ipm.Post | Post a note in a folder.
Ipm.StickyNote | Create a note.
Ipm.Recall.Report | Create a message recall report.
Ipm.Outlook.Recall | Retrieve sent messages from recipient Inboxes.
Ipm.Remote | Represent a Remote Mail message header.
Ipm.Note.Rules.ReplyTemplate.Microsoft | Edit rule reply templates.
Report | Report item status.
Ipm.Resend | Resend a failed message.
Ipm.Schedule.Meeting.Canceled | Send meeting cancellations.
Ipm.Schedule.Meeting.Request | Create meeting requests.
Ipm.Schedule.Meeting.Resp.Neg | Create decline meeting responses.
Ipm.Schedule.Meeting.Resp.Pos | Create accept meeting responses.
Ipm.Schedule.Meeting.Resp.Tent | Create tentative meeting responses.
Ipm.Note.Secure | Send encrypted notes to other people.
Ipm.Note.Secure.Sign | Send digitally signed notes to other people.
Ipm.Task | Create tasks.
Ipm.TaskRequest.Accept | Create accept task request responses.
Ipm.TaskRequest.Decline | Create decline task request responses.
Ipm.TaskRequest | Create task requests.
Ipm.TaskRequest.Update | Create updates to requested tasks.


Outlook fields and equivalent properties

Name of field in Outlook Field Chooser | Name of equivalent Outlook object model property
% Complete | PercentComplete
Account | Account
Actual Work | ActualWork
Address Selected | N/A
Address Selector | N/A
All Day Event | AllDayEvent
Anniversary | Anniversary
Assigned | DelegationState
Assistant's Name | AssistantName
Assistant's Phone | AssistantTelephoneNumber
Attachment | Attachments
Bcc | BCC
Billing Information | BillingInformation
Birthday | Birthday
Business Address | BusinessAddress
Business Address City | BusinessAddressCity
Business Address Country | BusinessAddressCountry
Business Address PO Box | BusinessAddressPostOfficeBox
Business Address Postal Code | BusinessAddressPostalCode
Business Address State | BusinessAddressState
Business Address Street | BusinessAddressStreet
Business Fax | BusinessFaxNumber
Business Home Page | BusinessHomePage
Business Phone | BusinessTelephoneNumber
Business Phone 2 | Business2TelephoneNumber
Callback | CallbackTelephoneNumber
Car Phone | CarTelephoneNumber
Categories | Categories
Cc | CC
Changed By | N/A
Children | Children
City | HomeAddressCity
Color | Color
Company | Companies
Company | CompanyName
Company Main Phone | CompanyMainTelephoneNumber
Complete | Complete
Computer Network Name | ComputerNetworkName
Contact | FormDescription .ContactName
Contacts | Links
Content | Body
Conversation | ConversationTopic
Country | HomeAddressCountry
Created | CreationTime
Customer ID | CustomerID
Date Completed | DateCompleted
Defer until | DeferredDeliveryTime
Department | Department
Distribution List Name | DLName
Do Not AutoArchive | NoAging
Download State | N/A
Due By | FlagDueBy
Due Date | DueDate
Duration | Duration
E-mail | Email1Address
E-mail 2 | Email2Address
E-mail 3 | Email3Address
E-mail Selected | N/A
E-mail Selector | N/A
End | End
Entry Type | Type
Expires | ExpiryTime
File As | FileAs
First Name | FirstName
Flag Status | FlagStatus
Follow-up Flag | FlagRequest
From | SentOnBehalfOfName
FTP Site | FTPSite
Full Name | FullName
Gender | Gender
Government ID Number | GovernmentIDNumber
Have Replies Sent To | ReplyRecipientNames
Hobbies | Hobby
Home Address | HomeAddress
Home Address City | HomeAddressCity
Home Address Country | HomeAddressCountry
Home Address PO Box | HomeAddressPostOfficeBox
Home Address Postal Code | HomeAddressPostalCode
Home Address State | HomeAddressState
Home Address Street | HomeAddressStreet
Home Fax | HomeFaxNumber
Home Phone | HomeTelephoneNumber
Home Phone 2 | Home2TelephoneNumber
Icon | FormDescription .Icon
Importance | Importance
In Folder | Parent
Initials | Initials
Internet Free Busy Address | InternetFreeBusyAddress
ISDN | ISDNNumber
Job Title | JobTitle
Journal | Journal
Junk E-Mail Type | N/A
Language | Language
Last Name | LastName
Last Saved Time | N/A
Location | Location
Mailing Address | MailingAddress
Mailing Address Indicator | N/A
Manager's Name | ManagerName
Meeting Status | MeetingStatus
Message | Body
Message Class | MessageClass
Message Flag | FlagStatus
Middle Name | MiddleName
Mileage | Mileage
Mobile Phone | MobileTelephoneNumber
Modified | LastModificationTime
Nickname | NickName
Notes | Body
Office Location | OfficeLocation
Optional Attendees | OptionalAttendees
Organizational ID Number | OrganizationalIDNumber
Organizer | Organizer
Other Address | OtherAddress
Other Address City | OtherAddressCity
Other Address Country | OtherAddressCountry
Other Address PO Box | OtherAddressPostOfficeBox
Other Address Postal Code | OtherAddressPostalCode
Other Address State | OtherAddressState
Other Address Street | OtherAddressStreet
Other Fax | OtherFaxNumber
Other Phone | OtherTelephoneNumber
Outlook Internal Version | OutlookInternalVersion
Outlook Version | OutlookVersion
Owner | Owner
Pager | PagerNumber
Personal Home Page | PersonalHomePage
Phone n Selected | N/A
Phone n Selector | N/A
PO Box | HomeAddressPostOfficeBox
Primary Phone | PrimaryTelephoneNumber
Priority | Importance
Private | Sensitivity
Profession | Profession
Radio Phone | RadioTelephoneNumber
Read | UnRead
Received | ReceivedTime
Recurrence | RecurrencePattern .RecurrenceType
Recurrence Pattern | N/A
Recurrence Range End | RecurrencePattern .PatternEndDate
Recurrence Range Start | RecurrencePattern .PatternStartDate
Recurring | IsRecurring
Referred By | ReferredBy
Remind Beforehand | ReminderMinutesBeforeStart
Reminder | ReminderSet
Reminder Override Default | ReminderOverrideDefault
Reminder Sound | ReminderPlaySound
Reminder Sound File | ReminderSoundFile
Reminder Time | ReminderTime
Reminder Topic | N/A
Remote Status | RemoteStatus
RequestStatus | N/A
Requested By | N/A
Required Attendess | RequiredAttendees
Resources | Resources
Response Requested | ResponseRequested
Retrieval Time | N/A
Role | Role
Schedule+ Priority | SchedulePlusPriority
Send Plain Text Only | N/A
Sensitivity | Sensitivity
Sent | SentOn
Show Time As | BusyStatus
Size | Size
Spouse | Spouse
Start | Start
Start Date | StartDate
State | HomeAddressState
Status | Status
Street Address | HomeAddressStreet
Subject | Subject
Suffix | Suffix
Team Task | TeamTask
Telex | TelexNumber
Title | Title
To | To
Total Work | TotalWork
Tracking Status | TrackingStatus
TTY/TTDD Phone | TTYTDDTelephoneNumber
User Field 1 | User1
User Field 2 | User2
User Field 3 | User3
User Field 4 | User4
Web Page | WebPage
ZIP/Postal Code | HomeAddressPostalCode


 Set properties for a form

Set properties for a form

With the form in design mode:

  1. Click the (Properties) page.

  2. To protect your form with a password, select the Protect form design check box, and then type a password in the Password and the Confirm boxes. Click OK.

  3. To be able to send a copy of the form in e-mail, select the Send form definition with item check box.

  4. To have the form show only for replies to messages, select the Use form only for responses check box.

  5. Select other options that you want.

    For Help on an option, click What's This? on the Help menu, and then click the option that you want.

    For more information about setting form properties, click here


 Set default properties for a form

Set default properties for a form

With your form in design mode, click on the tab for the Properties page.

Category You can specify a category for your form that will help to organize the forms in the New Form dialog box when you are selecting a form.

Sub-Category You can further refine the category by specifying a sub-category.

Always use Microsoft Word as the e-mail editor Lets you specify that Microsoft Word will be the editor for the Message portion (or control) of your form. This will add all the formatting options that are available with Word, such as spell checking and thesaurus. In order for these options to be fully available, though, the recipients of your form also need to have Word selected as their e-mail editor.

Template You can specify the Microsoft Word template that is used to format the text in the Message control of the form.

Contact When you click the Contact button, you have access to the Address Book. This allows you to select the names of people who are responsible for maintaining, upgrading, or providing information about this form. The contact information that you provide will show in the Forms Manager dialog box and the form Properties page.

Description You can type in the description for your form. This could include instructions for the use of the form as well as a full description of the form's purpose. This information will be displayed in the About dialog box on the Help menu of the form as well as in the Properties dialog box for the form.

Version Allows you to set a version number for this form.

Form Number Allows you to set a form number.

Change Large Icon When you click this button, a File Open dialog box allows you to select a different large icon for your form. Large icons appear in the form Properties dialog box.

Change Small Icon When you click this button, a File Open dialog box allows you to select a different small icon for your form. Small icons appear in the Outlook folder to represent an item of the type created with the form.

Protect Form Design When you check this box, you gain access to the Password dialog box. You can type in a password of your choice in the Password field and then retype it in the Confirm field. If you make a mistake when retyping, a message box will inform you and you'll have the opportunity to type the confirmation again. Setting a password for your form means that others are prevented from changing any of the attributes of your form after it is published. If you clear the checkbox, you no longer have password protection.

Set Password When you click this button, the Password dialog box will allow you to set a password for the protection of your form. This has the affect of checking the Protect Form Design checkbox as well.

Send form definition with item Specifies that the form definition is included when you send the form. This causes the form to be much larger than if this option is not selected. Checking this box creates a self-contained form that will allow your recipients to view the form even if they don't have access to the same forms library as the sender.

If you don't specify that the form definition should be sent with the item, the recipient will receive a regular form instead of the one that you have created. Setting this option allows recipients to open the item in the form on their computer, even though the form has not been installed on their Outlook system. This is especially useful for one-off forms that have been created for one-time use.

This option provides security and convenience for forms. If you send a form with this box checked, the recipients will see a Warning dialog box. They have the option of disabling the macros if the form is not from a trusted source. Harmful macros could delete or copy their files, or send mail from their mailbox to another user.

If network or file transfer time is an issue, an alternative to sending the form definition is to save the form and send it as an attachment to another form. Recipients can take the attached form and publish it in their own forms library.

For information about saving a form, click here

Use form only for responses Causes your form to be opened only if a related item is selected or opened. This option is used in situations when you have created a form that is intended only for replies. In another form, you can specify that your reply form will be used instead of the default reply form.

To use your form only for responses, check the Use form only for responses checkbox, and then publish your form. Open a second form in design mode. On the Actions page of the second form, you can specify your published form in the Reply or Reply to All action. To use your form as the default reply form, double-click the Reply action in the second form. You can select the name of your published reply form in the Form name: field of the Form Action Properties dialog box. This will cause your reply form to be used instead of the default reply form.


 Set the attributes of a form

Set the attributes of a form

The attributes of a form are set in design mode on the Properties and Actions pages. On the Properties page, the information such as Description, Category, and Form Number helps users find and identify your form in the New Form dialog box. If you do not want users to modify your form, you can protect a form by assigning a password to it.

For more information about protecting your form, click here

One very important attribute of your form is whether to send the form definition with the form. The form definition includes all the fields and the code you add to the form. If you do not plan to publish your form to a forms library, then you must select the Send form definition with item check box (Properties page). The form definition includes all the new data you add to the form when you send the form to another user. When you only plan to use your form one time and do not want to publish your form, this type of form is commonly referred to as a one-off form.

If you plan to publish your form to a forms library to which other users have access, such as an Organizational Forms Library or a public folder library, you do not need to send the form definition; it is stored in the library. The form definition can add considerable size to your form.

For more information about sending form definitions, click here

If you want to change how users reply to your form, click the Actions page. The Actions page lists the default Reply forms that are available. You can add your own custom Reply forms as well. For example, forms based on a new mail message have built-in Reply, Reply to All, Forward, and Reply to Folder forms. When users receive your form, the form will have buttons and menu commands so users can respond to the form. You can disable some or all of these default forms and set attributes for how these Reply forms appear.

For more information about setting default properties for a form, click here


 Add Help to a form

Add Help to a form

Perform the following steps to add a page of explanatory text to your form.

  1. Click the page to which you want to add text.

  2. On the Form menu, click Rename Page.

  3. In the Page name box, type Help, and then click OK.

  4. Drag a TextBox control from the Control Toolbox to the form.

  5. Right-click the TextBox control, and then click Properties on the shortcut menu.

  6. On the Display page, select Multi-line check box.

  7. Type the explanatory text that you want in the TextBox control.

  8. Right-click the TextBox control, and then click Properties on the shortcut menu.

  9. On the Display page, select the Read only check box.

Notes

  • Because a Help file cannot be associated with a form, you cannot use the HelpContextId property to create Help for an Outlook Form.

  • If the Compose page is different from the Read page, you may need to create separate Help pages.


 Change the icons associated with your form

Change the icons associated with your form

  1. In design mode, click the Properties page.

  2. Click Change Large Icon or Change Small Icon.

  3. Select the icon you want to use.


 Show or hide fields when printing and saving a form

Show or hide fields when printing and saving a form

  1. In design mode, right-click the field that you want, and then click Properties on the shortcut menu.

  2. Click the Validation page.

  3. Select or clear the Include this field for Printing and Save As check box.


 Hide or show form pages

Hide or show form pages

While in design mode:

  1. Click the page that you want to hide or show.

  2. On the Form menu, click Display This Page to clear or select the check mark.

Notes

  • Parentheses around a page name indicate the page is hidden. You cannot show the (Properties) or (Actions) pages.

  • If you drag a field or control to a hidden page, the page automatically shows.

  • To change what appears on the default or first page of an item, hide the first page, and then create a new version on one of the custom pages.

  • At least one page must be visible in a form.


 Require a value for a field or control

Require a value for a field or control

  1. In design mode, right-click the field or control that you want, and then click Properties on the shortcut menu.

  2. Click the Validation page.

  3. Select the A value is required for this field check box.


 Use Microsoft Word in the message control of your form

Use Microsoft Word in the message control of your form

  1. In design mode, click the Properties page.

  2. Select the Always use Microsoft Word as the e-mail editor check box.

  3. Enter the name of the template you want to use in the box below, or click Template to select from a list.


Understanding the forms cache

The forms cache is a folder located in the user's C:\Windows\…\Application Data\Forms folder that serves as a storage location for forms. The forms cache improves the load time of a form because commonly used forms are loaded from the hard disk rather than downloaded from the server. When a form is activated for the first time, the form definition file is copied from its forms library to the Forms folder. The forms cache keeps a temporary copy of the form definition in a subfolder whose name roughly matches the name of the form.

The form table, Frmcache.dat, also located in the Forms folder, is used to locate a form and to prevent multiple instances of the same form from being loaded in the cache. When a form is activated, Outlook checks to see if a form with the same message class is already in the cache. If not, it copies the form definition to the cache. In addition, if a change has been made to a form, Outlook copies the new form definition to the cache.

Outlook looks for forms in the following order. When a match is found, Outlook opens the form and does not search further.

  1. Standard Outlook forms, such as Note, Post, and Contact, in the Application Forms Library

  2. Forms already cached in the form cache

  3. Forms published in the folder that’s currently selected

  4. Forms in the Personal Forms Library

  5. Forms in the Organizational Forms Library

Because Outlook caches forms, you should try to avoid having more than one form with the same name or publishing the same form to more than one forms library. Forms used in a folder-based solution should be published only in the folder. If you’re developing a solution based on mail message forms, you can temporarily publish the forms in your Personal Forms Library. Once the form is finalized, you should publish the form to the Organizational Forms Library on the Microsoft Exchange Server and delete the form from your Personal Forms Library after making a backup of the form. If, for some reason, you need to publish a form in more than one location, you should be sure to keep all forms libraries up-to-date with the current version of the form.

Note It is not possible to disable the forms cache. If you set the size of the form cache to0, Outlook will not be able to open any custom forms.


Troubleshooting Forms

What do you need help with?

I can't find the form I created.

My data is not being saved with the form.

The form is always saved with the item.

The macro virus warning keeps appearing.

I can't change the default mail message form.

New items aren't using my custom form.

Old items aren't using my custom form.

A received mail or post form doesn't appear customized when read.

An incorrect version of a form is being used.

I can't find the message or notes property for an item.

The Click event of a control doesn't fire.

My program sets the Message control to read-only, but it still can be changed.

My solution doesn't run on other computers.

I cannot open a password-protected form.

Error: A field on this form requires a value.


 About standard fields in Microsoft Outlook

About standard fields in Microsoft Outlook

Microsoft Outlook provides standard fields for each standard item. Some fields are available in individual items, and you can add and remove all fields from a table or card view type.

For information about how to view all the fields for an item, click

The value for fields with the Yes/No data type is saved as -1 or 0. The value for fields with the Duration data type is saved as minutes.

What do you want more information about?

Outlook fields and equivalent properties

Standard fields in a Calendar item

Standard fields in a contact

Standard fields in a distribution list

Standard fields in a journal entry

Standard fields in a mail message

Standard fields in a note

Standard fields in a task

Standard fields in a post


 Use fields with controls

Use fields with controls

When you drag a field from the Field Chooser, the field automatically binds to the appropriate control. Unless you have a special requirement to use a standard control from the Control Toolbox, you should use the Field Chooser to provide access to fields on your forms.

When you put a control from the Control Toolbox on a form, you must bind the control to a form if you want to save a value to or from a control. In most cases, you bind TextBox, CheckBox, ListBox, ComboBox, and OptionButton controls to fields. Other controls, such as Label and Image controls, that contain static information with which the user does not interact are generally not bound to a field.

To bind a control to a field, right-click the control, and then click Properties on the shortcut menu. Click the Value tab. Click Choose Field, and then click a field or click New to create a custom field. Outlook fields are based on MAPI properties. In this way, the values of fields are stored with the item when you save or send the item. The controls from the Control Toolbox are only the visual containers for a field on a form. You can set the appearance of the control using its properties, but you cannot save a value. Controls only exist when the specific form appears that contains the controls. Fields can be used on any form. If you change a field value in one place, this value changes everywhere the field is used.

For example, to change the value of a custom field called Fax, you use the following code:

Item.UserProperties.Find("Fax").Value = "555-1234"

Note that since this is a field, you do not need to specify the page or the control the field is bound to. In the following code example, a control called txtFax is made invisible. When you work with a control, you must specify the page and the control name.

Item.GetInspector.ModifiedFormPages("General").("txtFax").Visible = False

You can bind a control to a field at run time by using the internal property named ItemProperty. The following example binds a TextBox to a field named Business Address.

Item.GetInspector.ModifiedFormPages("General").Textbox1.ItemProperty = "Business Address"

Note If you create a control by dragging a plain text field to a form, you cannot bind the control to a field of a different type. For example, you cannot drag a Subject field to a form and then bind it to a field containing an Email type (such as the To field).


 About custom fields and data types

About custom fields and data types

You can use custom fields in several ways in Outlook.

  • You can create new data-entry fields for a view or form so users can add their own custom information. For example, you can create a Date/Time field named "Last Talked To" in a contact folder and then add the field to a Phone List view.

  • You can create new views by combining the standard fields in a single column. For example, you can create a column that combines the State and Country fields in an address list to save space.

  • You can create a formula field to show information in a new way. For example, you can create a field that displays "Large" when a message is more than 10,000 bytes and "Small" when a message is under the same limit.

Any field that you create is stored in the folder in which you create it. To use a field in more than one folder, you must recreate the field in each folder.

You can create and view custom fields in table views and card views. You can create custom fields with the following data types in Outlook.

Data type | Use to represent
Combination | Combinations of values of fields and text in a column (table) or row (card). You can specify whether to show each field or show only the first non-empty field. You can also combine text with fields without the use of quotation marks. For examples of combination fields you can create, click [image] .
Currency | Numeric data as currency or mathematical calculations that involve money.
Date/Time | Date and time data.
Duration | Numeric data. You can enter a duration as minutes, hours, or days. Values are saved as minutes.
Formula | Calculations based on standard and custom fields. You can use any appropriate functions and operators to complete the formula. For examples of formula fields that you can create, click [image] .
Integer | Non-decimal numeric data.
Keywords | When filled in, this user-defined field is used to group and find related items similar to the way the Categories field is used in Outlook. Text with multiple values to be separated by commas. Each value can be grouped individually in a view.
Number | Numeric data or mathematical calculations except those that involve money. (For money, use Currency data type.)
Percent | Numeric data as a percentage.
Text | Text or combinations of text and numbers, such as addresses. Can be up to 255 characters long.
Yes/No | Data that contains only one of two values, such as Yes/No, True/False, On/Off. Yes/No fields can also be displayed as [image] or [image] .

Each of the data types except Combination, Formula, and Keywords has a series of standard formats you can use to show the values of the fields.

For information about standard formats that you can use with data types, click here


Difference between a field and a column

Usually, a column in a table contains the value of a single field, such as the Received field. However, you can show several fields in a column by using a Formula or Combination field. Fields can also be shown as rows in a card view or as controls on a form. A column is just one way to show the contents of a field.


 Create a simple field for a folder

Create a simple field for a folder

  1. Select the folder for which you want to create the field.

  2. On the View menu, select Current View, and click Customize Current View.

  3. On the View Summary dialog box, click Fields.

  4. Click New Field.

  5. In the Name box, type a name for the field.

  6. In the Type box, click the data type you want for the field. Do not select Combination or Formula.

    For information about standard formats for data types, click here

  7. In the Format box, select the format you want for the field.

  8. Click OK.

  9. Click Move Up and Move Down to position the field between the other fields in the view.

    To remove the field from the view, click Remove.


Examples of standard formats for data types

You can format fields that you create with different formats based on the data type. The following table provides a list of some of the formats that Outlook includes.

For a complete list of standard formats available for a field in a view, click Current View on the View menu, then click Format Columns. Select the field you want to format in the Available fields box, and then select a format in the Format list. If you don't find the format you want, you can create a custom format with a Formula data type and the Format function.

Data type | Standard format examples
Currency | $12,345.60 or ($12,345.60) $12,346 or ($12,346)
Date/Time | Monday, March 03, 1997 8:00 AM 3/03/97 8:00 AM March 3, 1997 Mon 3/3 8:00 AM 8:00 AM
Duration | 12h 12 hours 12h (Work Time) (see the Note below) 12 hours (Work Time) (see the Note below)
Integer | 1,234
Keywords | Text
Number | All Digits: 1,234.567 or -1,234.567 Truncated: 1,235 or -1,235 Scientific: 1235E+03 or -1235E+03 Computer: 64 K or 128MB or 1 GB
Percent | 65.4321% 65.43% or -65.43% 65% or -65%
Text | Text
Yes/No | Yes or No On or Off True or False or

Note Values entered in a field of a Duration data type with a regular format assume a 24-hour day.


 Create a combination field for a folder

Create a combination field for a folder

  1. Select the folder for which you want to create the combination field.

  2. On the View menu, select Current View, and click Customize Current View.

  3. On the View Summary dialog box, click Fields.

  4. Click New Field.

  5. In the Name box, type a name for the field.

  6. In the Type box, click Combination.

  7. Click Edit.

  8. To append each value for the fields that you want to use together, click Joining fields and any text fragments to each other.

    To show only the first field that is not blank, click Showing only the first non-empty field, ignoring subsequent ones.

  9. Click Field, point to the field set that you want, and then click the field that you want to appear.

  10. Repeat step 9 to add each field that you want to appear.

  11. Click OK twice.

  12. Click Move Up and Move Down to position the field between the other fields in the view.

    To remove the field from the view, click Remove.

Notes

  • Combination fields appear with the default format of the data type used. To display a data type with a custom format, you must create a formula field and use the Format function.

  • You cannot sort, group, or filter the contents of a combination field.


 Create a formula field for a folder

Create a formula field for a folder

  1. Select the folder for which you want to create the formula field.

  2. On the View menu, select Current View, and click Customize Current View.

    On the View Summary dialog box, click Fields.

  3. Click New Field.

  4. In the Name box, type a name for the field.

  5. In the Type box, click Formula.

  6. Click Edit.

  7. To insert a function in the formula, click Function, point to the function set that you want, and then click the formula that you want.

  8. For information about the functions that you can use to create a formula, click [image] . For information about the operators that you can use, click [image] .

  9. To insert a field in the formula, select the argument that you want to replace, click Field, point to the field set that you want, and then click the field that you want.

  10. For information about standard fields for each item type in Outlook, click [image] .

  11. Click OK twice.

  12. Click Move Up and Move Down to position the field between the other fields in the view.

  13. To remove the field from the view, click Remove.

Notes

  • Formula fields are updated with any change to a view. For example, if you change the width of a column, the formula fields are updated.

  • You cannot sort, group, or filter the contents of a formula field.


 Examples of Formula and Combination fields

Examples of Formula and Combination fields

What you want to show | Custom field | Result in custom field
Number of days since the item was received. (Formula field) | DateValue (Now())-DateValue ([Received]) & " Day(s)" | 6 Day(s)
Description of a meeting or appointment in Calendar. (Formula field) | "This meeting occurs " & [Recurrence Pattern] & " in " & [Location] | The meeting occurs every day from 12:00 P.M. to 1:30 P.M. in room 1231
Amount to be charged for a phone call recorded in the Journal at .75 a minute. (Formula field) | IIF ([Entry Type] = "Phone call" , Format ([Duration] * .75, "Currency"), "None") | $1.50
Description of a Message Flag. (Formula field) | IIF ( [Flag Status] = "2", [Message Flag] & " " & [Due By],"") | Follow up 3/5/97 8:00:00 A.M.
The first phone number recorded for a contact, in order of appearance in the formula. (Combination field) | [Business Phone] [Business Phone 2] [Home Phone] [Home Phone 2] [Car Phone] | (555) 555-1234
A description of a field combined with the field itself. (Combination field) | Task Due: [Due Date] | Task Due: 3/5/97 8:00:00 A.M.


Troubleshoot custom fields

What do you need help with?

The custom field I created is not visible.

When I try to sort, group, or filter a formula field or combination field, I receive an error message.


Set properties for controls

There are two types of properties for a control: Outlook properties and advanced properties. Outlook properties are the basic properties needed to design a control. Advanced properties offer additional functionality.

Outlook properties are set in the Properties dialog box, and must be set individually. Advanced properties are set in the Advanced Properties dialog box and can be set for multiple controls at once.

  • To set properties for a control, right-click the control, and then click Properties on the shortcut menu. Select the options that you want.

  • To set advanced properties for controls, select the controls that you want, right-click one of the controls, and then click Advanced Properties on the shortcut menu. Select the options that you want.

  • For information about how to select multiple controls, click here


 Change the name property of a control

Change the name property of a control

  1. In design mode, right-click the control you want, and then click Properties on the shortcut menu.

  2. On the Display page, type a name in the Name box.

Note Each control should have a unique name.

The following code example uses the ModifiedFormPages property of the current Inspector object to set the Name property of a CheckBox on a page named "Test" to "Selection."

Item.GetInspector.ModifiedFormPages("Test").Checkbox1.Name = "Selection"


 Validate user input to a field

Validate user input to a field

You can require that any field, or any control that is bound to a field, have a value. For example, you can set the exact text, range of numbers, or any other criteria for the field. You can also show a custom message (based on a validation formula) that tells users how to fill in the field if their entries do not match the value you want. For example, you can limit the number of characters that can be entered in a TextBox.

For examples of validation formulas, click [image] .

What do you want to do?

Require a value for a field or control

Create a validation formula and message


Examples of validation formulas

Use | To evaluate
<50 | Numbers less than fifty
>50 | Numbers greater than fifty
=50 | Equal to fifty
? | The number of characters


 About the Control Toolbox

About the Control Toolbox

The Control Toolbox identifies the controls you can add to a Frame or page of a form.

You can customize the Control Toolbox in many ways including the following:

  • Add pages to the Control Toolbox.

  • Move controls from one page in the Control Toolbox to another.

  • Rename Control Toolbox pages.

  • Add other controls, including ActiveX controls, to the Control Toolbox.

  • Copy modified controls from the form to the Control Toolbox.

    For example, OK and Cancel buttons are special types of CommandButtons. If you copy OK and Cancel templates to the Control Toolbox, you can quickly add them to other forms.

Note When you add a control to a form by using the Control Toolbox, the control is not bound to a field. For information about how to bind a control to a field, click [image] .


 About ToolTips and control tips

About ToolTips and control tips

Both ToolTips and control tips are short, descriptive phrases that appear when the user holds the mouse pointer briefly over a control or another part of the user interface. The difference between ToolTips and control tips is that Microsoft Outlook provides ToolTips to developers at design time, and developers provide control tips to end-users at run time.

You can customize ToolTips for controls and for the Control Toolbox.

A control tip is set with the ControlTipText property.


 Add a page to the Control Toolbox

Add a page to the Control Toolbox

  1. If the Control Toolbox is not visible, click Control Toolbox [image] .

  2. Right-click the label of any page in the Control Toolbox, and then click New Page on the shortcut menu.


Add custom controls to the Control Toolbox

You can add a modified control (based on modifications made to the advanced properties) to the Control Toolbox. You can also add other custom controls to the Control Toolbox, such as ActiveX controls that are not part of Outlook.

You can use a variety of custom controls in Outlook forms, but there are some limitations. Although Outlook supports most ActiveX properties and methods, it does not support custom event handling. The Click event is the only event for which you can write code. To access the methods of an ActiveX control, use your VBA Object Browser to browse ActiveX control methods.

What do you want to do?

Add a modified control to the Control Toolbox

Add other custom controls to the Control Toolbox


 Change the name and control tip of a page in the Control Toolbox

Change the name and control tip of a page in the Control Toolbox

  1. If the Control Toolbox is not visible, click Control Toolbox [image] .

  2. Right-click the label of the page that you want in the Control Toolbox, and then click Rename on the shortcut menu.

  3. In the Caption box, type a new name for the page.

  4. In the Control Tip Text box, type new text for the control tip.


 Change the order of pages in the Control Toolbox

Change the order of pages in the Control Toolbox

  1. If the Control Toolbox is not visible, click Control Toolbox [image] .

  2. Right-click the label of any page in the Control Toolbox, and then click Move on the shortcut menu.

  3. In the Page Order box, click the name of a page that you want to move.

  4. Click Move Up or Move Down.


 Customize an icon for a control in the Control Toolbox

Customize an icon for a control in the Control Toolbox

  1. If the Control Toolbox is not visible, click Control Toolbox [image] .

  2. Right-click the icon for the control you want in the Control Toolbox, and then click Customize control name on the shortcut menu.

  3. To change the ToolTip, enter text in the Tool Tip Text box.

  4. To edit the icon, click Edit Picture. In the Color box, click the color that you want to use, and then click the pixel in the Picture box where you want to apply the color. Click OK.

  5. To assign a new bitmap, click Load Picture. In the File name box, type a name for the file that contains the bitmap you want to use as the icon. The bitmap cannot be larger than an icon.


 Delete a control from the Control Toolbox

Delete a control from the Control Toolbox

  1. If the Control Toolbox is not visible, click Control Toolbox [image] .

  2. In the Control Toolbox, right-click the control that you want to delete, and then click Delete control name on the shortcut menu.


 Delete a page in the Control Toolbox

Delete a page in the Control Toolbox

  1. If the Control Toolbox is not visible, click Control Toolbox [image] .

  2. Right-click the label of the page that you want to delete in the Control Toolbox, and then click Delete Page on the shortcut menu.

Note All controls on a page are deleted when the page is deleted.


 Import or export a Control Toolbox page

Import or export a Control Toolbox page

  1. If the Control Toolbox is not visible, click Control Toolbox [image] .

  2. To import a page, right-click the label of any page in the Control Toolbox, and then click Import Page on the shortcut menu.

    To export a page, right-click the label of the page, and then click Export Page on the shortcut menu.

  3. In the File name box, enter the name of the page that you want to import or enter the name of the file to which you want to export a page.

Note Exporting a page does not remove it from the Control Toolbox.


 Move a control to another page in the Control Toolbox

Move a control to another page in the Control Toolbox

  1. If the Control Toolbox is not visible, click Control Toolbox [image] .

  2. Drag a control on any page to the label of another page. Hold the mouse pointer over the label until the page appears on top, and then drag on to the page.

Note If the page to which you want to move a control is not visible, increase the width of the Control Toolbox to show all the pages, and then drag the control to the appropriate page.


 Show or hide the Control Toolbox

Show or hide the Control Toolbox

  • In design mode, click Control Toolbox [image] .


About groups of controls

A group is two or more controls on a form that you can work with as a single unit. You can include any control on the form in a group. Once controls belong to a group, you can work with the entire group, or you can select a single control.

There are many ways to work with groups and the controls in groups. After you select a group, you can do any of the following.

  • Size all controls in the group at the same time. For information, click [image] .

  • Separate controls in the group so each is independent of the others. For information, click [image] .

  • Show the group shortcut menu for quick access to commands that affect the group. For information, click [image] .

  • Select a single control within the group without separating controls in the group. You can then change property settings of the selected control without affecting any other control in the group. For information, click [image] .


 Active controls and selected controls

Active controls and selected controls

In design mode, all controls have an active state and a selected state. When a control is active, it means you are working with the contents of the control; when a control is selected, it means you are working with the control itself.

Most controls are automatically selected when you put them on the form. In design mode, sizing handles appear around the control border when the control is selected. If you deselect the control, you can select it again by clicking the control.

Clicking a control that is selected puts the control in the active state. In this state, you can directly edit the control Caption or Value property, depending on the control.

In both the selected and the active state, you can use DEL, CTRL+X, and CTRL+C for the Delete, Cut, and Copy commands, respectively. In the selected state, these commands are available on the shortcut menu and affect the control itself. In the active state, these commands affect whatever text is selected inside the control; if no text is selected, these commands have no effect. These commands are not available on the shortcut menu for active controls.


 Add a control to a form

Add a control to a form

Use any of the following methods to add a control from the Control Toolbox to your form. You can also use these methods to insert a control in a Frame, TabStrip, or MultiPage on the form.

  • Click a control in the Control Toolbox and then click in the form. The control appears in its default size. You can then drag the border of the control to change its size.

  • Drag a control from the Control Toolbox to the form. The control appears in its default size.

  • Double-click the control in the Control Toolbox, and then click in the form once for each control you want to create. For example, to create four command buttons, double-click the CommandButton control in the Control Toolbox, and then click four times in the form.


 Align controls

Align controls

  1. Select the controls that you want to align to part of the dominant control.

    How?

  2. On the Layout menu, point to Align, and then click one of the following.
    Click | To
    Left | Align controls to the left edge of the dominant control.
    Center | Align the center of controls to the vertical center of the dominant control.
    Right | Align controls to the right edge of the dominant control.
    Top | Align controls to the top edge of the dominant control.
    Middle | Align the center of controls to the horizontal center of the dominant control.
    Bottom | Align controls to the bottom edge of the dominant control.
    To Grid | Align the upper-left corner of controls with their nearest grid point. Note that this option is not based on the position of the dominant control.


Align text in a control

This procedure is only available for the ComboBox, Label, and TextBox controls.

  1. Right-click the control you want, and then click Advanced Properties on the shortcut menu.

  2. To set the TextAlign property, click the property and enter a value in the Apply box.
    Set the TextAlign property to | To
    Left | Align the text with the left edge of the control
    Right | Align the text with the right edge of the control
    Center | Center the text relative to the length of the control


 Allow multiple lines of text in a control

Allow multiple lines of text in a control

  1. In design mode, right-click the control you want, and then click Properties on the shortcut menu.

  2. On the Display page, select the Multi-line check box.

    The following code example uses the ModifiedFormPages property of the current Inspector object to set the multi-line property of a TextBox on a page called "Test."

    Item.GetInspector.ModifiedFormPages("Test").Textbox1.MultiLine = True


 Assign a control tip, caption, and accelerator key to a control

Assign a control tip, caption, and accelerator key to a control

  1. Right-click the control that you want, and then click Advanced Properties on the shortcut menu.

  2. To set the property, click the property and enter a value in the Apply box.
    Set the property | To assign
    ControlTipText | The string you want to use as the control tip
    Caption | The string you want to use as the caption
    Accelerator | A single character as the value for ALT+Key entry. If you use a character from the caption of the control, the character is underlined

Note You can also set the value of these properties with code. For example, to set the caption of the Label1 control on the Message page, use:

Item.GetInspector.ModifiedFormPages("Message").Label1.Caption = "New Caption"


 Create a set of OptionButton controls

Create a set of OptionButton controls

By default, all OptionButton controls in a container are part of a single option group. This means that selecting one of the buttons automatically sets all other option buttons on the page to False.

If you want more than one option group on the page, there are two ways to create additional groups:

  • Use the GroupName property to identify related buttons. This method reduces the number of controls required on the form, which can reduce the hard disk space required and improve the performance of the form. If you want to create an option group in a TabStrip (which is not a container), you must use the GroupName property.

  • Put related buttons in a Page, MultiPage, or Frame on the form.

What do you want to do?

Create a set of OptionButtons using the GroupName property

Add a control to a form


 Enable or disable a control on a page

Enable or disable a control on a page

  1. In design mode, right-click the control you want, and then click Properties on the shortcut menu.

  2. On the Display page, select or clear the Enabled check box.

    The following code example uses the ModifiedFormPages property of the current Inspector object to set the Enabled property of a CheckBox on a page named "Test."

    Item.GetInspector.ModifiedFormPages("Test").Checkbox1.Enabled = False


 Give a control a 3-D appearance

Give a control a 3-D appearance

  1. In design mode, right-click the control you want, and then click Advanced Properties on the shortcut menu.

  2. Click SpecialEffect, and then click the option you want in the box above.

    The following code example uses the ModifiedFormPages property of the current Inspector object to set the SpecialEffect property of a CheckBox on a page named "Test."

    Item.GetInspector.ModifiedFormPpages("Test").Checkbox1.SpecialEffect = 2

Note For a list of available special effects, click [image] .


 Hide or show a control

Hide or show a control

  1. In design mode, right-click the control you want, and then click Properties on the shortcut menu.

  2. On the Display page, select or clear the Visible check box.

    The following code example uses the ModifiedFormPages property of the current Inspector object to set the Visible property of a CheckBox on a page named "Test."

    Item.GetInspector.ModifiedFormPages("Test").Checkbox1.Visible = False


 Make a control read-only

Make a control read-only

  1. In design mode, right-click the control you want, and then click Properties on the shortcut menu.

  2. On the Display page, select the Read only check box.

    The following code example uses the ModifiedFormPages property of the current Inspector object to make TextBox1 read-only.

    Item.GetInspector.ModifiedFormPages("P.2").TextBox1.ReadOnly = True


 Move a control one unit at a time

Move a control one unit at a time

  1. In design mode, right-click the control you want, and then click Properties on the shortcut menu.

  2. On the Display page, type a number in the Top and Left boxes.


Show the shortcut menu for controls and groups of controls

To show the shortcut menu for a | Right-click
page | the caption of the appropriate page.
MultiPage | anywhere in the control, but not on the caption of any page in the control.
Group of controls (groups created with the Group command) | anywhere inside the rectangle that surrounds the group.
tab | the caption of the appropriate tab.
TabStrip | anywhere in the control, but not on the caption of any tab in the control.
Any other control or container | the control or container.

Note The commands on a shortcut menu vary based on the object you select. For example, if you select multiple controls that aren't in a group, the shortcut menu includes the Group command; the shortcut menu for a text box does not include this command.


 Ways to protect sensitive information

Ways to protect sensitive information

Many applications use data that is for authorized users only. The following list suggests ways you can protect sensitive information in a form. Note however, that the fields associated with a form can still be exposed in a view.

  • Write code that makes a control (and its data) invisible to unauthorized users. To identify a particular user in code, use the following code.

    Application.GetNameSpace("MAPI").CurrentUser

    The Visible property makes a control visible or invisible.

  • Write code that sets the control foreground and background to the same color when unauthorized users run the application. This hides the information from unauthorized users. The ForeColor and BackColor properties determine the foreground color and the background color.

  • Disable the control when unauthorized users run the application. The Enabled property determines when a control is disabled.

  • Require a password to alter a form. For more information about setting passwords to protect a form, click here

  • Require a password for access to the application or a specific control. You can use placeholders as the user types each character. The PasswordChar property defines placeholder characters.

  • If the form only appears in a public folder, you can set permissions for the folder to determine who can open the form. For information, click [image] .

Note Using passwords or any other techniques listed above can improve the security of your application, but these methods do not guarantee the prevention of unauthorized access to your data.


 Show or hide the grid

Show or hide the grid

  • In design mode, click Show Grid on the Layout menu.


 Set the grid size

Set the grid size

  1. In design mode, click Set Grid Size on the Form menu.

  2. In the Height and Width boxes, type the dimensions that you want.

Tip If you use the Arrange command (Layout menu) to position command buttons in your application, use small grid settings so that you can position the command buttons closer to the edge of the form.


 Turn on or off sizing controls to the grid

Turn on or off sizing controls to the grid

  • In design mode, click Snap to Grid on the Layout menu or click the Snap to Grid icon on the toolbar.


 Center controls in a form

Center controls in a form

  1. Select the controls or groups of controls that you want to center. The dominant control does not affect this procedure.

    How?

  2. On the Layout menu, point to Center in Form, and then click Horizontally or Vertically.


Right-align a control on a form

  1. Drag a Label control from the Control Toolbox to the left of the spot where you would like to align a control.

  2. Remove any text from the Caption property.

  3. Right-click the label, and then click Properties on the shortcut menu.

  4. On the Display page, select the Resize with form check box.

  5. Create the control you want to align.

  6. Place the control to the right of the Label control.


 Space controls

Space controls

  1. Select the controls for which you want to adjust spacing.

  2. On the Layout menu, point to Horizontal Spacing or Vertical Spacing, and then click one of the following.
    Click | To
    Make Equal | Make all horizontal and vertical spaces between controls the same size. The amount of horizontal and vertical space will vary based on the area available to show controls and the combined width of all controls.
    Increase | Increase the space between controls by one grid block.
    Decrease | Decrease the space between controls by one grid block.
    Remove | Remove the space between controls. The controls do not overlap, but are immediately adjacent to each other.


 Size controls

Size controls

  1. Select the controls that you want to size to the dominant control.

    How?

  2. On the Layout menu, point to Make Same Size, and then click one of the following.
    Click | To
    Width | Make all selected controls the same width as the dominant control.
    Height | Make all selected controls the same height as the dominant control.
    Both | Make all selected controls the same height and width as the dominant control.

Note To size a control to fit its contents (both its picture and any text assigned to the Caption or Text property), select the control, and then click Size to Fit on the Layout menu.


Automatically resize controls

You can set controls to resize horizontally or vertically when a user changes the size of the form. The size of the control changes in proportion to the size of the form. For example, when a user changes the size of a message, the body resizes automatically.

Resize a control horizontally with the form

Resize a control vertically with the form

Resize a control horizontally and vertically with the form


 Create a group of controls

Create a group of controls

  1. Select each control that you want to include in the group. The dominant control does not affect this procedure.

    How?

  2. On the Layout menu, click Group.


Select and edit a control within a group

  1. Select the group of controls.

  2. Select a single control within the group. The sizing handles around the group become lighter, and dark sizing handles appear on the selected control.

  3. Make the changes that you want to the selected control properties. Any change you make affects only the selected control.

  4. When you're finished, click anywhere in the group, but don't click on the selected control. The group is still selected.

  5. Select another control in the group or go on to another task.


Separate controls in a group

  1. Select the group of controls.

  2. On the Layout menu, click Ungroup.


Select multiple controls and the dominant control

You can select more than one control in three ways. In addition, when you select multiple controls, one of the controls becomes a reference for the rest and is called the dominant control.

Selection method | What is selected | Dominant control
SHIFT+CLICK | All controls in an invisible rectangle around the selected controls. | First control you select
CTRL+CLICK | Individual controls, one at a time. | Last control you select.
Select Objects pointer in Control Toolbox | All controls that fall within or touch a rectangle you draw. | Control nearest the mouse pointer when you begin drawing the rectangle.

Tips

  • Occasionally the CTRL+CLICK method may select additional controls that are near to or adjacent to the selected controls. For more accuracy, use the Select Objects pointer method.

  • If you CTRL+CLICK twice on a selected control, that control becomes the dominant control.


 Use z-order to layer controls

Use z-order to layer controls

  1. Select the controls you want to reposition in the z-order.

  2. On the Layout menu, point to Order, and then click one of the following.
    Click | To move control
    Bring to Front | To the top of the z-order.
    Send to Back | To the bottom of the z-order.
    Bring Forward | Up one position in the z-order.
    Send Backward | Down one position in the z-order.

Notes

  • You can't Undo or Redo layering commands, such as Send to Back or Bring to Front.

  • If the form includes any ListBox, Frame, or MultiPage controls, these controls automatically move as close as possible to the top of the stack. For example, applying Send Backward to a ListBox, Frame, or MultiPage control moves the control below other ListBox, Frame, or MultiPage controls, but does not move the control below any other type of control in the stack. Similarly, applying Bring Forward to a control other than a ListBox, Frame, or MultiPage control moves the control closer to the top of the stack, but does not move the control above any ListBox, Frame, or MultiPage control in the stack.

    Visually, this means that if a ListBox, Frame, or MultiPage control and any other Microsoft Forms controls are in the same location on a form, the ListBox, Frame, or MultiPage control always appears on top of the other control(s). If a ListBox, Frame, or MultiPage control is in the same place as another ListBox, Frame, or MultiPage control, the z-order of the controls determines which control appears on top of the other.


Should I use a MultiPage or a TabStrip?

If you use a single layout for data, use a TabStrip, and then map each set of data to its own tab. If you need several layouts for data, use a MultiPage, and then assign each layout to its own page.

Unlike a page of a MultiPage, the client region of a TabStrip is not a separate form but a portion of the form that contains the TabStrip. The border of a TabStrip defines a region of the form that you can associate with the tabs. When you place a control in the client region of a TabStrip, you are adding a control to the form that contains the TabStrip.


 Assign a control tip, caption, and accelerator key to a page or tab

Assign a control tip, caption, and accelerator key to a page or tab

This procedure sets properties on a Page or Tab in a MultiPage or TabStrip control only.

  1. In design mode, select a page or tab in a MultiPage or TabStrip control.

    How?

    Be sure to select an individual page or tab, not the corresponding MultiPage or TabStrip. When a page or tab is selected, a rectangle appears around its caption.

  2. Right-click the caption of the selected page or tab, and then click Rename on the shortcut menu.

  3. In the Control Tip Text box, type the string you want to use as the control tip

  4. In the Caption box, type the string you want to use as the caption.

  5. In the Accelerator Key box, type a single character. Use a character from the caption of the control. Note that the selected character is underlined in the control caption.

Tip To assign a control tip for a MultiPage or TabStrip, use the ControlTipText property. If you assign a control tip to a MultiPage or a TabStrip, control tips for the individual page or tab objects within the MultiPage do not appear.


 Change the order of pages in a MultiPage or TabStrip

Change the order of pages in a MultiPage or TabStrip

This procedure sets properties on a Page or Tab only in a MultiPage or TabStrip control.

  1. In design mode, select any page in the MultiPage or TabStrip control.

    How?

  2. Right-click the caption of the page, and then click Move on the shortcut menu.

  3. In the Page Order box, click the page you want to move.

  4. Click Move Up or Move Down.

Note You can also change the page order by changing the Index property. The index of the first page is 0; the index of the second page is 1, and so on.


 Set tab order of controls on a page

Set tab order of controls on a page

  1. In design mode, right-click on a page in a form, but not on a control, and then click Tab Order on the shortcut menu.

  2. Select the name of a control you want to reposition in the tab order.

  3. Click Move Up or Move Down.

Note You can also set the tab order by changing the TabIndex property. The tab index of the first control in the tab order is 0; the tab index of the second control is 1, and so on.


 Add items to a list

Add items to a list

You can add items to a list box or a combo box at design time and at run time. To save its contents in an item, a ListBox and a ComboBox control must be bound to a field.

For information about how to bind fields to controls, click [image] .

What do you want to do?

Add items to a list at design time

Add items to a list at run time


 Create a list box

Create a list box

  1. In design mode, drag the ListBox control from the Control Toolbox to the form.

  2. Right-click the list box, and then click Advanced Properties on the shortcut menu.

  3. To create a standard list box, set the ListStyle property to Plain. To set the property, click the property and enter a value in the Apply box.

    To create a list box with option buttons or check boxes, set the ListStyle property to Option.

  4. Fill the list at design time or run time.

    How?

Note When the ListStyle property is set to Option, the MultiSelect property determines whether check boxes or option buttons appear in the list. When MultiSelect is set to Single, option buttons appear in the list. When MultiSelect is set to Multi or Extended, check boxes appear in the list.


 Match entries in a list to entries typed by users

Match entries in a list to entries typed by users

  1. In design mode, drag the ListBox or ComboBox control from the Control Toolbox to the form.

  2. Right-click the list box or combo box, and then click Advanced Properties on the shortcut menu.

  3. To set the MatchEntry property, click the property and enter a value in the Apply box.
    Set the MatchEntry property to | To
    No matching | Provide no matching
    First letter | Compare the most recently typed letter to the first letter of each entry in the list (the first match in the list is selected)
    Complete | Compare the user's entry and an exact match in an entry from the list

Notes

  • The matching feature resets after 2 seconds (6 seconds in the Far East version). For example, if you have a list of the 50 United States and you type "CO" quickly, you will find "Colorado." But if you type "CO" in longer than 2 seconds, you will find "Ohio" because the auto-complete search resets between letters.

  • If you select Complete matching, it is a good idea to sort the list entries alphabetically (you can use the TextColumn property to do this). If the list is not sorted alphabetically, matching may not work correctly. For example, if the list includes Alabama, Louisiana, and Alaska, respectively, then "Alabama" is considered a complete match if the user types "ala." In fact, this result is not complete because there are two entries in the list that could match what the user entered. Sorting alphabetically eliminates this.


Things you can do with a multicolumn ListBox or ComboBox

To control the column widths of a multicolumn ListBox or ComboBox, you can specify the width, in points, for all the columns in the ColumnWidths property. Specifying zero for a specific column hides that column of information.

If you want to hide all but one column of a ListBox or ComboBox from the user, you can identify the column of information to appear by using the TextColumn property.

Similarly, you can control which column of values is used for the control when the user makes a selection by specifying the column number in the BoundColumn property.


Align a picture on a control

  1. Right-click the control that has the bitmap you want to align, and then click Advanced Properties on the shortcut menu.

  2. Set one or all of the following properties. To set the property, click the property and enter a value in the Apply box.
    Set the property | To
    PictureAlignment | Center the picture within the Image or align any corner of the picture with the corresponding corner of the Image.
    PictureSizeMode | Clip, stretch, or zoom the picture within the Image (stretching can distort the picture but zooming does not).
    PictureTiling | Show multiple copies of the picture within the Image.


Assign a picture to a control

  1. Right-click the control you want to assign a picture to, and then click Advanced Properties on the shortcut menu.

  2. Set the Picture property. To set the property, click the property and enter a value in the Apply box.

  3. In the Load Picture dialog box, enter the name of the picture in the File name box.

Note If the picture is larger than the control, Outlook scales the picture to fit the control.


Assign a picture to a form

  1. On the form, right-click the page you want to assign a picture to, and then click Advanced Properties on the shortcut menu.

  2. To set the property, click the property and enter a value in the Apply box.
    Set the property | To the value
    Picture | The name of the picture you want to use
    PictureAlignment | TopLeft
    PictureSizeMode | Clip
    PictureTiling | True


 Change the appearance of a control

Change the appearance of a control

Outlook includes several properties you can use to define the appearance of controls in your form: ForeColor, BackColor, BackStyle, BorderColor, BorderStyle, and SpecialEffect.

  • ForeColor determines the foreground color. The foreground color applies to any text associated with the control, such as the caption or the control contents.

  • BackColor and BackStyle apply to the control background. The background is the area within the control boundaries, such as the area surrounding the text in a control, but not the control border. BackColor determines the background color. BackStyle determines whether the background is transparent. A transparent control background is useful if your form has a background picture.

    For ForeColor and BackColor, you can use the color scheme defined by your system, or you can use a custom color that you pick from the color palette. Using a system color, such as Menu Text, ensures that your form matches the colors and palette used by your applications. Custom colors do not always appear the same across systems and screen resolutions, but they do offer the widest choice of colors.

  • BorderColor, BorderStyle, and SpecialEffect apply to the control border. You can use BorderStyle or SpecialEffect to choose a border type. Only one of these two properties can be used at a time. When you assign a value to one of these properties, the system sets the other property to None. With SpecialEffect, you can choose one of several border styles, but you can only use system colors for the border. BorderStyle supports only one border style, but you can choose any color that is a valid setting for BorderColor. BorderColor specifies the color of the control border and is only valid when you use BorderStyle to create the border.

Outlook supports transparency, the display of whatever is behind an object instead of its background, in two areas: the background of certain controls and in bitmaps used on certain controls.

You can show a bitmap on many controls. Certain controls support transparent bitmaps — that is, bitmaps in which one or more background colors are transparent. Bitmap transparency is not controlled by any control property; it is controlled by the color of the lower-left pixel in the image. Outlook does not provide a way to edit a bitmap and make it transparent; you must use a picture editor for this purpose.

Bitmaps are always transparent on the following controls: CheckBox, CommandButton, Label, OptionButton, and ToggleButton. In Outlook, the following do not support transparent bitmaps: the form, Frame control, Image control, and MultiPage control.

Transparent pictures sometimes have a hazy appearance. If you do not like this appearance, show the picture on a control that supports opaque images. If you use a transparent bitmap on a control that does not support transparent bitmaps, the bitmap appears correctly, but you can't see what's behind the bitmap.

What do you want to do?

Use a system color for a background or foreground

Use a custom color for the background or foreground of a control

Set the background color of a form

Make a control transparent


Delete a picture from a control

  1. Right-click the control, and then click Advanced Properties on the shortcut menu.

  2. Highlight the value of the Picture property (the word "bitmap").

  3. Press DELETE.


 Test a form in run mode

Test a form in run mode

To switch between the design mode and the run mode (as it appears when used) of the form, on the Form menu, click Run This Form.

Note You can test the form outside the Outlook design environment. Open a new instance of the form. For information, click [image] .

Enter information in the form, send or post it, and then open the form to make sure it appears correctly. If the form is not correct, you can make changes to it. For information about how to edit a form, click


 Save and distribute a form

Save and distribute a form

There are three ways to save a form that you have created.

  • Save the form in the open folder. Use this option when you want to send a form to others by using e-mail or you do not plan to share the form.

  • Save the form as a file. Use this option when you want to work with the form in another program or you want to save the form as a template; you do not plan to share the form with others or you want to send the form to others by using e-mail.

  • Save the form in a forms library. Use this option when you want to save a form to a location (library) for easy access. There are three forms libraries.
    • Personal Forms Library. Forms saved in this library are accessible only to you and are stored in your mailbox. These forms are available on the item menu from the Choose Form command. Use this library when you have created a form for your own personal use, such as a form to track mileage.

    • Outlook Folders. Forms saved in this library can be accessible to everyone (in a public folder,) or only to you (in a private folder). If the form is saved in a library on your hard disk, it is accessible to you only while in the folder. These forms are available on the item menu while you are in the folder. Use this library when saving forms to a specific folder, generally a public folder. For example, in a customer-tracking public folder, you could have a meeting report form and a customer profile form.

    • Organizational Forms Library. Forms saved in this library are accessible to everyone in your organization and are stored on the server. (You must have write permission to save to the server; for information, see your administrator.) These forms are available on the item menu from the Choose Form command. Use this library when you want to make the form available to everyone in your organization, such as a form to report vacation time. Saving to this library provides a quick and easy way to distribute and update forms.

What do you want to do?

Save a form in the open folder

Save a form as a file

Save a form in a forms library

Send a form to others by using e-mail


Save a form with the item (one-off forms)

When you’re creating solutions using custom forms in Microsoft Outlook, it’s important to understand how Outlook is using your custom form in relation to the items in a folder.

For instance, if you want to create a custom contact form to replace the default Outlook contact form, you would typically follow these steps:

  1. Start with a new, default contact item to use as the basis for your custom form.

  2. Modify the form to suit your needs.

  3. Publish the form to the Contacts folder.

  4. Set the form as the default form for the Contacts folder by changing the folder properties.

In this typical scenario, information about the form (the form definition) is not saved with each item. Instead, the form is stored in the location where it was published and is referenced using the Message Class field. This way, each item only stores the data associated with it, and its size is relatively small.

However, it’s possible to have Outlook store the form definition within individual items in a folder. These items are called one-off items and will always use the form definition that is stored within the item instead of the published form.

In most situations, the form definition should not be stored within the item. The most common exception to this is a custom mail message form. If you are using Microsoft Exchange Server, you can publish a custom mail message form to the Organizational Forms Library so that it will always be available for use by everyone within the organization. In this way, you would not have to store the form definition within the item. However, if you are not using Microsoft Exchange Server, or if you are sending the form to another organization where the form is not available, you should select the Send form definition with item check box on the Properties page of the form when in design mode. This will ensure that the recipient will be able to view the mail message with the custom form.

Note If the recipient is still unable to view your custom form, be sure that you customized or disabled the Read page of the custom mail form.

If the custom form contains VBScript, Outlook will display the macro virus warning unless the form is published in the Microsoft Exchange Server Organizational Forms Library.

The following scenarios commonly result in items becoming one-off items.

  • You have a folder-based solution whereby the form is published in the folder and the items are using the published form. You open an existing item in a folder, make changes to the form in design mode, and then save the item.

    Since the form definition has changed and the form was not republished, Outlook will save the new form definition with the item. If you want to change the form for all of the items in the folder, instead of opening an existing item, follow these steps:

    1. Open a new item based on your custom form.

    2. Make form design changes to that item.

    3. Republish the form with the same name.

    4. Close and do not save changes to the item.

    All of the items in the folder will now use the updated custom form the next time the items are opened, because the message class of the items still refers to the published form.

  • VBScript code in the custom form changed the form definition of the item.

    If VBScript code within an item programmatically changes the form, in many cases this will result in the form definition being saved with the item. The following Outlook object model methods most commonly cause this behavior:

    • UserProperties .Add

    • Methods and properties of the FormDescription object.

    • Some methods or properties of controls, such as Enabled.

    • Methods and properties of the Actions collection object.

Although solutions and situations vary greatly, there are some signs you should be aware of that can indicate that an item has become a one-off item.

  • A macro virus warning unexpectedly appears, indicating that the item itself, and not just a published form, contains VBScript code.

  • The size of an item increases unexpectedly.

  • An item’s icon changes unexpectedly.


 Using Visual Basic with Outlook

Using Visual Basic with Outlook

You can use Visual Basic to customize and extend Microsoft Outlook. Outlook allows you to control Outlook by using Visual Basic, Visual Basic for Applications and VBScript. Which you use depends on what you want your program to do.

Visual Basic is a full-featured programming language you can use to create stand-alone applications or dynamic-link libraries (DLLs) that extend other applications. Visual Basic for Applications is a subset of Visual Basic that is run within an application to extend its capabilities. VBScript is a simplified version of Visual Basic for Applications and is run within an Outlook item. In all cases, these programming languages control Outlook through its object model.

Learn about the Outlook object model.

If you want to create a separate application that accesses data stored by Outlook and uses Outlook to send and receive messages, use Visual Basic to create the application (you can also use other programming languages, such as C++, to control Outlook through its object model). You can also use Visual Basic to create a DLL that can extend Outlook as a COM add-in.

You use Visual Basic for Applications in one of two ways: You can use Visual Basic for Applications in other applications (such as Microsoft Excel or Microsoft Word) to automate Outlook, or you can use Visual Basic for Applications within Outlook to control Outlook. If you expect your users to be using another application most of the time, and you want to give them the ability to send a message using Outlook or to access information stored by Outlook, write Visual Basic for Applications programs in that application that control Outlook through the Outlook object model. If, on the other hand, you want to write Visual Basic code that customizes how Outlook works (like a macro), use Visual Basic for Applications within Outlook.

You can extend the functionality of Outlook forms by using VBScript. VBScript programs are stored within a form. Because the program code is contained within the form, it can be sent with an item to another user. An important consideration in choosing which kind of the Visual Basic programming language you will use is the type of events you want your program to respond to. Because VBScript code is associated with a particular item, code that responds to events in specific items (such as when a particular item is opened or a value in a field is changed) is easiest to write using VBScript. If, on the other hand, you want your program to respond to events that occur in the application, in Windows Explorer, in folders, or in all items, then you should write your program using Visual Basic or Visual Basic for Applications.

Code written for Visual Basic or Visual Basic for Applications often does not work in VBScript without modification. For example, you must replace all built-in constants written in Visual Basic for Applications with the literal numeric values of those constants in VBScript. And VBScript uses only the Variant data type.

Learn about constants and variables in VBScript.

In Outlook Visual Basic for Applications and VBScript, when you reference the Application object to use CreateObject or GetObject, you simply use Application. For example, the following code displays the Tasks folder:

Set olMAPI = Application.GetNameSpace("MAPI")
olMAPI.GetDefaultFolder(13).Display

In Visual Basic or Visual Basic for Applications in other applications, you must explicitly create the Application object:

Set myOlApp = CreateObject("Outlook.Application")
Set olMAPI = myOlApp.GetNameSpace("MAPI")
olMAPI.GetDefaultFolder(olFolderTasks).Display


Using Visual Basic for Applications in Outlook

Visual Basic for Applications in Microsoft Outlook makes it easy to control Outlook within Outlook itself. Using Visual Basic for Applications in Outlook, you can create macros that perform complex or repetitive tasks automatically. You can also develop program code that responds to Outlook events, allowing you to automate common tasks (such as arranging windows when Outlook starts).

Visual Basic for Applications in Outlook allows you to take full advantage of the Outlook object model, including the wide range of application-level events, without requiring you to run an external application (such as another Microsoft Office application or an application developed using Microsoft Visual Basic). And unlike form scripts developed using VBScript, Outlook Visual Basic for Applications code is always available in the application; an item does not have to be open to run the code.

All Outlook Visual Basic for Applications code is contained in a project. The project is associated with a particular user, so all users who run Outlook on a computer can customize Outlook to meet their own needs. A project can contain code modules and user forms (note that user forms are not the same as Outlook forms).

You use the Visual Basic Editor to create and remove modules, to design user forms, and to edit code in modules. This editor provides a powerful set of tools, including a built-in object browser and debugger to make developing and troubleshooting code easy. You can even use the Visual Basic Editor in Outlook to develop and test code that you can then copy to a standalone Visual Basic application or a Visual Basic for Applications application in another Microsoft Office application.

You can export a module to a file; this makes it easy to share your programs with other users, who can use the Visual Basic Editor to import the module into their own Outlook Visual Basic for Applications projects.

Learn about writing an Outlook macro, responding to Outlook events, and designing Visual Basic for Applications forms.


Writing an Outlook macro

A macro is any public subroutine in a code module. A function or a private subroutine cannot be a macro, and a macro cannot be located in a class or form module.

To create a new macro

  1. In Outlook, point to Macro on the Tools menu, and then click Visual Basic Editor.

  2. In the Project window, double-click the module you want to contain the macro.

  3. On the Insert menu, click Procedure.

  4. In the Name box, type a name for the macro. The name cannot contain spaces.

  5. Click OK.

    The template for the macro subroutine appears in the code module window.

  6. Type the code you want to run in the body of the subroutine.

For more information about using the Visual Basic Editor, see the online Help in the editor.

Once you’ve created a macro, you can create a menu item or toolbar button that will run the macro when you click it.


Using Outlook Visual Basic for Applications to respond to Outlook events

You write an event procedure (also known as an event handler) to respond to events that occur in Microsoft Outlook. For example, you can write an event procedure that automatically maximizes the explorer window when Outlook starts.

Events are associated with particular objects. The Application object is the topmost object, and is always available (that is, it does not have to be created). You can add an Application event procedure in the ThisOutlookSession module window simply by selecting Application in the left list and then selecting the event in the right list.

Adding an event handler for objects other than the Application object requires a couple of more steps.

First, you must declare a variable using the WithEvents keyword to identify the object whose event you want to handle. For example, to declare a variable representing the OutlookBarPane object, you would add the following to a code module.

Dim WithEvents myOlBar as Outlook.OutlookBarPane

You can then select myOlBar in the left list of the module window and then select the event in the right list. The Visual Basic Editor will then add the template for the event procedure to the module window. You can then type the code you want to run when the event occurs. The following example shows code added to the BeforeNavigate event procedure for the OutlookBarPane object.

Private Sub myOlBar_BeforeNavigate(ByVal Shortcut As OutlookBarShortcut, Cancel As Boolean)
    If Shortcut.Name = "Notes" Then
        MsgBox "You cannot open the Notes folder."
        Cancel = True
    End If
End Sub

The final step is to add code to set the object variable to the object whose event you want to handle. This code can exist in a macro, or if you want the event to be handled whenever Outlook runs, you can put it in the Startup event procedure, as in the following example.

Private Sub Application_Startup()
    Set myOlBar = Application.ActiveExplorer.Panes(1)
End Sub


Working with forms in the Visual Basic Editor

You can use the Visual Basic Editor to design a form that allows your users to interact with your Microsoft Visual Basic for Applications program. Unlike an Outlook form, a Visual Basic for Applications form is not used to display an Outlook item, nor can a control on a Visual Basic for Applications form be bound to an item field.

Your Visual Basic for Applications program can use a Visual Basic for Applications user form to gather information from your users; your program can then use this information to set properties of new or existing Outlook items. For example, a program that creates a boilerplate mail message could use a Visual Basic for Applications form to allow the user to enter the specific information for the message to be sent. When the user closes the form, the program uses the information in the form to set the properties of the mail message and then sends the message.

The following sample uses the text in two text box to add information to a message before sending it.

Private Sub CommandButton1_Click()
    Dim myMail As Outlook.MailItem
    Set myMail = Application.CreateItem(olMailItem)
    With myMail
        .To = TextBox1.Text
        .Subject = "Book overdue: " & TextBox2.Text
        .Body = "Please return this book as soon as possible."
    End With
    myMail.Send
End Sub

You can also use controls to display information about Outlook items, folders, and other features of the Outlook object model. The following example shows how to fill a combo box control with the subjects of the items in the user’s Inbox.

Dim myItems As Outlook.Items
Set myItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
For x = 1 To myItems.Count
    ComboBox1.AddItem myItems.Item(x).Subject
Next x

For more information about creating and using forms in the Visual Basic Editor, see the Visual Basic Editor online Help.


Automating Outlook from a Visual Basic Application

Because Microsoft Outlook supports Automation, you can control Outlook from any program written with Microsoft Visual Basic. Automation provides a standard method for one application to access the objects, methods, properties, and events of other applications that support Automation.

The Outlook object model provides all of the functionality necessary to manipulate data stored in Outlook folders, and it provides the ability to control many aspects of the Outlook user interface.

To start an Outlook automation session, you can use either “early” or “late” binding. Late binding uses either the GetObject or the CreateObject function to initialize Outlook. For example, the following code sets an object variable to the Outlook Application object, which is the highest-level object in the Outlook object model. All automation code must first define an Outlook Application object to be able to access any other Outlook objects.

Dim objOL as Object
Set objOL = CreateObject("Outlook.Application")

To use early binding, you first need to set a reference to the Outlook object library. You can then use the following syntax to start an Outlook session.

Dim objOL as Outlook.Application
Set objOL = New Outlook.Application

Most programming solutions interact with the data stored in Outlook. Outlook stores all of its information in Messaging Application Programming Interface (MAPI) folders. After you set an object variable to the Outlook Application object, you will commonly set a Namespace object to refer to MAPI, as shown in the following example.

Set objOL = New Outlook.Application
Set objNS = objOL.GetNameSpace("MAPI")
Set objFolder = objNS.GetDefaultFolder(olFolderContacts)

Once you have set an object variable to reference the folder that contains the items you wish to work with, you use appropriate code to accomplish your task, as shown in the following example.

Sub CreateNewDefaultOutlookTask()
    Dim objOLApp As Outlook.Application
    Dim NewTask As Outlook.TaskItem
    ' Set the application object
    Set objOLApp = New Outlook.Application
    ' You can only use CreateItem for default items
    Set NewTask = objOLApp.CreateItem(olTaskItem)
    ' Display the new task form so the user can fill it out
    NewTask.Display
End Sub


Automating Outlook from other Microsoft Office applications

You can use Microsoft Visual Basic for Applications in any Microsoft Office application to control Microsoft Outlook. For example, if you are developing a cross-application solution using one primary application and several secondary applications, you can write Visual Basic for Applications code in the primary application to automate Outlook to send messages and to store and retrieve information in Outlook items. For example, in Microsoft Excel you can write routines that send a workbook to an Outlook distribution list.

To control Outlook objects from outside Outlook, you must establish a reference to the Outlook object library from the project in which you are writing code. To do this, use the References dialog box in the Visual Basic Editor in the primary application. You can then write code that returns a reference to the Outlook Application object. Through this reference, your code has access to all the objects, properties, methods, and constants defined in the Outlook type library.

There are several ways to return a reference to the Outlook Application object:

  • You can use the CreateObject function to start a new session of Outlook and return a reference to the Application object that represents the new session.

  • You can use the GetObject function to return a reference to the Application object that represents a session that’s already running. Note that because there can be only one instance of Outlook running at any given time, GetObject usually serves little purpose when used with Outlook. CreateObject can always be used to access the current instance of Outlook or to create a new instance if one does not exist. However, you can use error trapping with the GetObject method to determine if Outlook is currently running.

  • You can use the New keyword in several types of statements to implicitly create a new instance of the Outlook Application object using the Set statement to set an object variable to the new instance of the Application object. You can also use the New keyword with the Dim, Private, Public, or Static statement to declare an object variable. The new instance of the Application object is then created on the first reference to the variable.

Automating Outlook from a Visual Basic Application provides examples of using these methods of referencing the Outlook Application object.


Working with Outlook events

Microsoft Outlook provides a wide range of events through which it can notify your Microsoft Visual Basic, Microsoft Visual Basic for Applications, and VBScript programs that a significant change has occurred. For example, Outlook events can notify a program when a new item has been opened or that the user has changed the Outlook Bar.

To receive notification of a significant event, write an event-handler procedure. Depending on whether the event is handled in Visual Basic or Visual Basic for Applications or in VBScript, this is either a Sub or a Function that Outlook calls when the event occurs, which is sometimes referred to as the event firing. The code you put in the event handler allows your program to respond appropriately to the event and, in some cases, even lets your program cancel the default action associated with the event, such as preventing a mail item from being sent.

Types of Events

Outlook events can be divided into two main categories: item-level events and application-level events.

Item-level events pertain to a particular item, and are typically handled by VBScript code contained within the form associated with the item. These events notify your program when an item has been opened, sent or posted, saved, or closed, and when the user has replied to or forwarded a message or initiated a custom action. Item-level events can also notify your program when the user has clicked a control on the form or when an item property has changed.

Learn about form events, control events, and field events.

Application-level events are typically handled by Visual Basic or Visual Basic for Applications because they pertain to more than the items associated with a particular form. Application-level events can pertain to the application itself, to explorer collections and windows (including the Outlook Bar), inspector collections and windows, folders and folders collections, items collections, and synchronization objects.

Learn about application-level events.

Responding to Events

To respond to item-level events, add event-handler procedures to the script of the form that displays the item. For example, to run code when an item is opened in the form, add a procedure like the following to the script in the form.

Function Item_Open()
    MsgBox "A new item has opened in this form."
End Function

Responding to application-level events is somewhat more involved because steps must be taken to associate the event handler with the part of Outlook in which the event is occurring. Learn about writing an application-level event handler.

Order of Events

Except for certain form events, your program cannot assume that events will occur in a particular order, even if they appear to fire in a consistent sequence. The order in which Outlook calls event handlers might change depending on other events that might occur, or the order might change in future versions of Outlook.


Customizing Outlook using COM add-ins

You can use Microsoft Visual Basic version 5.0 or later (version 6.0 is preferred) or the Microsoft Office 2000 Developer to create a COM add-in to extend and enhance Microsoft Outlook. The Microsoft Office 2000/Visual Basic Programmer’s Guide provides detailed information about using these tools to develop COM add-ins.

Creating a COM add-in involves two major steps:

  1. Implement the IDTExtensibility2 interface in a class module of a dynamic link library (DLL).

  2. Register the COM add-in.

Implement the IDTExtensibility2 interface

The IDTExtensibility2 interface consists of five event procedures. To implement this interface in a Visual Basic program, set a reference to the Microsoft Add-In Designer object library and then add the following statement to the Declarations section of a class module:

Implements IDTExtensibility2

You can then add the empty event procedures to the code window of the class module and add your own program code to the procedures. You can also copy the empty procedures from Outlook COM Add-in Template.

Register the COM add-in

In order to work with Outlook, the add-in DLL must be registered. The DLL's class ID is registered beneath the \HKEY_CLASSES_ROOT subtree in the registry.

In addition, information about the add-in must be added to the registry. This information provides the add-in’s name, description, target application, initial load behavior, and connection state.

Note If you use Microsoft Visual Basic 6.0 or Office 2000 Developer to design your COM add-in, the add-in designer will perform the steps required to register the COM add-in for you.

The following example shows the contents of a sample registry-editor (.reg) file that illustrates how to register an Outlook COM add-in.

[HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\Addins\SampleAddIn.AddInIFace]
"FriendlyName"="Sample Add-in"
"Description"="Sample Outlook Add-In"
"LoadBehavior"=dword:00000008

When the COM add-in is first registered, LoadBehavior can be set to any of the following flags.

Value | Description
2 | Load at startup. COM add-in is to be loaded and connected when Outlook starts.
8 | Load on demand. COM add-in is to be loaded and connected only when the user requests it, such as by using the COM Add-ins dialog box.
16 | Connect first time. COM add-in is loaded and connected the first time the user runs Outlook after the COM add-in has been registered. The next time Outlook is run, the COM add-in is loaded when the user requests it. Use this value if your COM add-in modifies the user interface to allow the user to request the COM add-in be connected on demand (by clicking a button, for example).

After the COM add-in is registered and loaded, the LoadBehavior value can be combined with either of the following two flags to indicate current connection state of the COM add-in.

Flag | Description
0 | Disconnected
1 | Connected

To connect the COM add-in, set the Connected flag in LoadBehavior; clear the flag to disconnect the COM add-in.

The FriendlyName value specifies the name of the COM add-in as it’s displayed in the COM Add-in dialog box. The Description value provides additional information about the COM add-in.


 Adding custom property pages

Adding custom property pages

Creating a custom property page for Microsoft Outlook involves four major steps:

  1. Create the page as an ActiveX control.

  2. Implement the PropertyPage object.

  3. Write a procedure that sets the value of the Dirty property and calls the OnStatusChange method.

  4. Create a Common Object Model (COM) add-in that contains an event procedure for OptionsPagesAdd.

Create the page as an ActiveX control

A custom property page in Outlook is an ActiveX control that’s implemented along with a dynamic link library (DLL) that’s designed as a COM add-in. The easiest way to create a custom property page is using Microsoft Visual Basic version 6.0. This version of Visual Basic provides templates and tools that simplify the process of creating both ActiveX controls and COM add-ins.

When you create the ActiveX control, you populate it with the controls your user will require to set the properties your page is designed to support. Because Outlook might resize the control when it displays the property page in the dialog box, the control’s Initialize event should position and size the child controls dynamically, depending on the final values of the control’s Width and Height properties.

The dialog box in which the custom property page is displayed has three buttons below the property pages: an OK button, a Cancel button, and an Apply button. When the user clicks the OK button, changes to properties on all pages in the dialog box are applied and the dialog box is closed. If the user clicks the Cancel button, no properties are changed and the dialog box is closed. If the user clicks the Apply button, any changes to properties are applied but the dialog box remains open. You should design your property page to respond appropriately when the user clicks these buttons. Later sections in this topic describe how to notify Outlook that the status of your property page has changed and how Outlook notifies your program when the changed property values should be applied.

Implement the PropertyPage object

The PropertyPage object is an abstract object; that is, its interfaces are defined but not implemented by Outlook. If your custom property change will rely on the Apply or Help button of the parent dialog box, the module that contains the custom property page ActiveX control must implement the PropertyPage object. To implement the object, the module must have a reference set to the Microsoft Outlook 9.0 Object Library and must contain the following statement.

Implements Outlook.PropertyPage

The module must then contain code that implements the methods and properties of the PropertyPage object. The following table describes these procedures.

Procedure | Description
Dirty property | Called by Outlook in response to the OnStatusChange method to determine whether the user has changed a value on the property page.
Apply method | Called by Outlook to notify your program that the user has clicked the OK or the Apply button. Usually this procedure applies any property values changed by the user in the property page.
GetPageInfo method | Called by Outlook to obtain the Help file and topic associated with the property page.

Write a procedure that sets the Dirty property and calls the OnStatusChange method

Most commonly, changes to property values are not applied immediately in response to user interaction with the controls that let the user specify those values. Instead, the values are applied when the user clicks OK or Apply on the dialog box. The Apply button is grayed until the user changes a value on a property page. To notify Outlook that the user has changed a value on your property page, your program should call the OnStatusChange method and then return True when Outlook queries the Dirty property.

Create a COM add-in containing an event procedure for the OptionsPagesAdd event

The OptionsPagesAdd event gives your program the opportunity to add your custom property page to the Outlook Options dialog box (if the event is fired for the Application object) or the folders Properties dialog box (if the event is fired for the NameSpace object). When Outlook calls this event procedure, it passes a PropertyPages collection object. Your event procedure uses the Add method of the collection to add the PropertyPage object implemented by your program to the collection.


About using VBScript in Outlook

Microsoft VBScript is a powerful scripting language based on Microsoft Visual Basic that enables you to control objects, folders, forms, items, and controls within a form. For example, you can change properties and values of controls on a page, modify the default Microsoft Outlook item events, and even create automated procedures, such as mailing a notice to all the contacts in a Contacts folder.

You add VBScript code to an Outlook form to respond to Click events that are fired by controls on the form, or to respond to events fired by the items that have the same message class as the form. VBScript makes it especially easy to respond to item events because the VBScript code executes in the context of the item, so you don’t have to set an object variable to point to the item. In addition, VBScript code is compact and can be contained within a form sent to other users.

With VBScript, you have full access to the Microsoft Outlook object model, except for two areas: VBScript code cannot respond to events other than item and form events, and you cannot use named constants defined in the Outlook object type library. Learn about common things you can do with VBScript and working with Outlook events.

You can also use Visual Basic for Applications in Outlook to respond to Outlook events and to create macros that automate procedures. Unlike VBScript code, however, Visual Basic for Applications code cannot be contained in a form and so cannot accompany an item that is sent to other users.

For more information about using VBScript, see Create custom forms by using VBScript.


 How can I prevent the VBScript code from running?

How can I prevent the VBScript code from running?

To prevent any VBScript code from running, hold down the SHIFT key. For example, hold down SHIFT while you open an item to prevent the VBScript code for the Open event from running.


Variants supported in VBScript

Microsoft VBScript in Outlook uses only the Variant data type.

A Variant is a special kind of data type that can contain different kinds of information, depending on how it's used. Because Variant is the only data type in VBScript, it's also the data type returned by all functions in VBScript.

At its simplest, a Variant can contain either numeric or string information. A Variant behaves as a number when you use it in a numeric context and as a string when you use it in a string context. That is, if you're working with data that looks like numbers, VBScript assumes that it is numbers and does the thing that is most appropriate for numbers. Similarly, if you're working with data that can only be string data, VBScript treats it as string data. Of course, you can always make numbers behave as strings by enclosing them in quotation marks (" ").


 Using the Script Editor

Using the Script Editor

The Microsoft Script Editor allows you to add VBScript procedures that respond to events generated by items or form controls.

To open the Script Editor

  1. Open an item of the type to which you want to add code.

  2. On the Tools menu, point to Forms and then click Design This Form.

  3. On the Form menu, click View Code.

The Script Editor makes it easy to insert the template for an item event handler.

To insert a blank item event handler

  1. On the Script menu, click Event Handler.

  2. Select the event you want to respond to, and then click OK.

The Script Editor can move the insertion point to a specific line of code. This makes it easy to debug the script when Microsoft Outlook reports an error at a specific location.

To move to a specific line

  1. On the Edit menu, click Go To.

  2. In the Line Number box, type in the number of the line of code to which you want to go.

Learn about the Script Debugger.

Learn about the Outlook object browser.


 About the Outlook object browser

About the Outlook object browser

The Microsoft Outlook object browser displays the classes, properties, methods, and events available from the Outlook object library. The object browser lets you view and insert these objects into the Script Editor and obtain information about the syntax for using the object.

Learn about viewing and using the object browser.

View the Outlook object hierarchy.

Learn about recent changes to the Outlook object library.


 About the Outlook script debugger

About the Outlook script debugger

The Microsoft Script Debugger provides you with a comprehensive debugging environment for testing and correcting errors in the VBScript code that you created for your Microsoft Outlook forms. The Script Debugger is a shared component that can also be used to track down errors in any Microsoft ActiveX-enabled scripting language and to debug Java applets, beans, and ActiveX components.

The Microsoft Script Debugger lets you debug both client scripts and server scripts.

The Microsoft Script Debugger works the way many debuggers do, by allowing you to:

  • View the source code of the script that you are debugging.

  • Control the pace of the script execution.

  • View and change variable and property values.

  • View and control script flow.

The script debugger is only available in Outlook at run time.

Learn about using the Script Debugger in Outlook.


Set global variables for a form

A global variable is available to any procedure in a form while the script is running. To set a global variable, assign the value to the variables before any procedures.


 Referencing controls on an Outlook form

Referencing controls on an Outlook form

If you need to refer to a control on an Outlook form within a procedure, you must also reference the inspector, page, and controls collection that contains the control, even if you are referencing the control with its own event procedure. The following example shows how to change the caption of a command button when it’s clicked. To test this example, in design mode create a command button with the default name CommandButton1 on the page P.2.

Sub CommandButton1_Click
    Set myButton = Item.GetInspector.ModifiedFormPages("P.2")_
       .Controls("CommandButton1")
    myButton.Caption = "New Caption"
End Sub


Common things you can do with VBScript

The following are common things you can do with VBScript in an Outlook Form.

What do you want to do?

Create an Outlook item

Add a Click event for a control

Add an Outlook event

Reference the active user

Change a property of a control

Change the value of a field

Reference a folder

Use properties from the Microsoft Exchange Server global address list

Make a control read-only

Put a list of fields and values in the message body


Form Events

Form events occur when something happens to an item displayed in a form, such as when it's saved or opened or when a user-defined action is started.

Most often, form events are handled by VBScript code within the form itself. Learn about working with Outlook events.

Some events can be cancelled. That is, your event handler can prevent Microsoft Outlook from performing the default action associated with the event. For example, you can write an event handler for the Forward event to prevent an item from being sent to recipients who are not on a list of approved recipients. Learn about canceling an event.

The following table lists the form events supported by Outlook.

Event

Cancelable? |  | Description
AttachmentAdd | No | Occurs when an attachment has been added to the item
AttachmentRead | No | Occurs when an attachment has been opened for reading
BeforeAttachmentSave | Yes | Occurs before an attachment is saved
BeforeCheckNames | Yes | Occurs before Outlook starts resolving names in the recipients collection of the item
Close | Yes | Occurs before Outlook closes the inspector displaying the item
CustomAction | Yes | Occurs before Outlook executes a custom action of an item
CustomPropertyChange | No | Occurs when a custom item property has changed
Forward | Yes | Occurs before Outlook executes the Forward action of an item
Open | Yes | Occurs before Outlook opens an inspector to display the item
PropertyChange | No | Occurs when an item property has changed
Read | No | Occurs when an item is opened for editing by a user
Reply | Yes | Occurs before Outlook executes the Reply action of an item
ReplyAll | Yes | Occurs before Outlook executes the Reply to All action of an item
Send | Yes | Occurs before Outlook sends the item
Write | Yes | Occurs before Outlook saves the item in a folder


Control Events

Outlook form controls support only one event, the Click event.

A control bound to a field does not fire the Click event. You must handle the appropriate field event to detect a user’s interaction with a control bound to a field.

The following controls fire the Click event whenever a user clicks anywhere in the control.

CheckBox

CommandButton

Frame

Image

Label

OptionButton

ToggleButton

The following controls fire the Click event when the user selects an item in the list.

ComboBox

ListBox

The following controls do not support the Click event.

MultiPage

ScrollBar

SpinButton

TabStrip

TextBox

While the MultiPage control itself does not support the Click event, an individual Page on a MultiPage control will fire the Click event if the user clicks inside the client area of the page, but not if the user clicks the tab associated with the page.

To detect a change in a TextBox control, bind the control to a field and then handle the appropriate field event.


Field Events

Microsoft Outlook provides two events to notify your program that a field (property) in an item has changed. The PropertyChange event is fired whenever a standard Outlook field in an item has changed. Outlook fires the CustomPropertyChange event whenever a user-defined field changes.

A control that is bound to a field does not fire the Click event, whether the control was selected from the Control Toolbox and subsequently bound to a field, or was selected from the Field Chooser. Consequently, you must use the PropertyChange or CustomPropertyChange event to detect user interaction with a bound control.


Canceling an event

Microsoft Outlook calls event handlers in your program to allow your program to respond to such events as actions that the user takes or changes in the message store. Each event is accompanied by a default action that Outlook performs as a result of the event. For example, when the Open event occurs for an item, by default Outlook displays the item in an inspector window.

Some events only notify your program that a particular event has occurred. For these events, your event handler simply responds to the event. With other events, Outlook allows your event handler to cancel the event, that is, to instruct Outlook not to perform the default action associated with the event. In the case of the Open event, for example, your program can prevent Outlook from displaying the item in an inspector. If an event can be cancelled, the reference topic describing the event indicates how to cancel the event.

If an event can be cancelled, an event handler written in Microsoft Visual Basic or Microsoft Visual Basic for Applications receives a parameter that it sets before returning to indicate whether the event should be cancelled. For example, an event handler for the Open event written in Visual Basic for Applications might look like this. This example assumes that the value of OpenOK is set elsewhere.

Sub myItem_Open(byRef Cancel as Boolean)
    If OpenOK Then
        Cancel = False ' Outlook performs default action
    Else
        Cancel = True  ' Outlook does not perform default action
    EndIf
End Sub

Because of limitations in VBScript, however, this syntax cannot be used. An event handler for the Open event in the script of an item must be written as a function. To cancel the event, the value of the function is set to False before returning, as in the following example.

Function Item_Open()
    If OpenOK Then
        Item_Open = True  ' Outlook performs default action
    Else
        Item_Open = False ' Outlook does not perform default action
    End If
End Function


 About the order of events

About the order of events

The following events occur in the order specified when a user completes an action.

Events | When
Open | A form is opened to compose an item.
Send , Write, Close | An item is sent.
Write, Close | An item is posted.
Write | An item is saved.
Close | An item is closed.
Read, Open | An item is opened in a folder.
Reply | A user replies to an item's sender.
ReplyAll | A user replies to an item's sender and all recipients.
Forward | The newly-created item is passed to the procedure after the user selects the Forward action for an item.
PropertyChange | One of the item's standard properties is changed.
CustomPropertyChange | One of the item's custom properties is changed.
CustomAction | A user-defined action is initiated.

The Click event occurs only when you have defined it for a control in the Script Editor.


 Test tips for using VBScript in Outlook

Test tips for using VBScript in Outlook

There are several ways to test code in Outlook. If there is a syntax error in the code, when you run the form, an error message appears with the line number of the code. You can then go to the specific line of code. You can also use the Script Debugger and other methods to isolate run-time errors.

What do you want to do?

Go to a line of code

Use the Script Debugger

Use message boxes to return values

Set global variables for a form

Use the PropertyChange event to test procedures


About the object environment

There are two ways to write code for Outlook:

  • From outside the application, such as by using Microsoft Visual Basic or Microsoft Visual Basic for Applications in Microsoft Excel or another application.

  • From inside the application, such as by using Visual Basic for Applications or by using VBScript with an Outlook form.

Learn more about the differences between using Visual Basic for Applications and VBScript

View the Outlook object hierarchy

Learn about recent changes to the Outlook object library

The major components of the Outlook object model are:

Application The top of the object hierarchy that represents the entire application. Enables you to reference other objects in the application and create items and objects. For example, this code creates an appointment in Outlook Visual Basic for Applications or VBScript:
Application.CreateItem(1).Display
NameSpace Represents the MAPI message store where all the Outlook items are stored. Provides methods for logging on and off Outlook and for referencing the default folders such as Mailbox, Inbox, Contacts, and others. For example, this code references the active user in Outlook Visual Basic for Applications or VBScript:
Application.GetNameSpace("MAPI").CurrentUser
Explorer Represents the Outlook window. Enables you to show, return, and close the active window. For example, this code shows the active Outlook window in Outlook Visual Basic for Applications or VBScript:
Application.ActiveExplorer.Display
Folders There are two folder objects, the Folders collection object that enables you to work with collections of folders and the MAPIFolder object that enables you to work with a single folder. For example, this code shows the collection of folders named Personal Folders in Outlook Visual Basic for Applications or VBScript:
Application.GetNameSpace("MAPI").Folders("Personal Folders")
Outlook items There are two item objects, the Items collection object that enables you to work with items within a folder and the item objects that represents the standard item types in Outlook, such as MailItem that represents a mail message. In VBScript, the active item is assumed, so you do not need to enter the object model to reference it. For example, this code sets the Subject field of the active message in VBScript:
Item.Subject = "New Subject"
Inspector References forms. Use to show forms and pages. For example, this code shows the Options page of a form in Outlook Visual Basic for Applications or VBScript:
Application.ActiveInspector.SetCurrentFormPage("Options")
AddressEntry | Each AddressEntry object in the AddressEntries collection holds information that represents a person or process to which the messaging system can deliver messages.
AddressList | The AddressList object is an address book that contains a set of AddressEntry objects. The entire hierarchy is available through the parent AddressLists collection.
Exception | The Exception object holds information about one instance of an AppointmentItem object which is an exception to a recurring series. Unlike most of the other Outlook objects, the Exception object is a read-only object.
Control There are two control objects, the Controls collection object that enables you to work with all the controls on a page and the specific control object that enables you to work with a control. For example, this code sets the Caption of a CommandButton control named "CommandButton1" on a page named "Test" in VBScript:
Item.GetInspector.ModifiedFormPages("Test").Controls("CommandButton1").Caption = "New Caption"


Constants and variables in VBScript

In VBScript, constants must be referenced by their numeric values. The constant string does not work and returns a value of 0, which gives unpredictable results.

For a list of all the constant values, click [image] .

There are two types of variables. Procedure-level variables that are used only within a procedure and script-level variables that are available to all the procedures within your script. Declare script-level variables at the top of your script. Declare procedure-level variables inside procedures. You can use procedure-level variables with the same name in different procedures because each variable is recognized only by the procedure in which it's declared. When the procedure exits, the variable ends. Variables that refer to Outlook objects can be either procedure-level or script-level variables. However, the value of the variable must be set within a procedure. Do not attempt to access Outlook objects outside of a procedure.

Rules about variables:

  • Must begin with an alphanumeric character.

  • Cannot contain an embedded period.

  • Cannot exceed 255 characters.

  • Cannot use more than 127 procedure-level variables (arrays count as a single variable).

  • Cannot use more than 127 script-level variables.


Referencing fields

When you need to access the fields in an item, the method you use depends on whether the field is a standard, built-in Microsoft Outlook field, or a custom field.

In either case, you do not access the field directly. Instead, you refer to the field as a property of the item you’ re working with.

For example, to retrieve the text from the Subject field of a mail message, you use the Subject property of the item, as shown in the following VBScript example.

mySubject = Item.Subject

If the field is a custom (user-defined) field, you access it using the UserProperties property of the item, as shown in the following VBScript example. This example assumes that the item already contains a custom field named ReferredBy.

MyReferral = Item.UserProperties("ReferredBy")


Reference a folder

To reference a folder by the name of the folder, use the following code.

Application.GetNameSpace("MAPI").Folders("Personal Folders").Folders("Product Ideas")

To reference a folder by a number, use the following code. In this example, the first folder in the folder collection Personal Folders is referenced.

Application.GetNameSpace("MAPI").Folders("Personal Folders").Folders(1)

To reference any of the default Outlook folders, use the GetDefaultFolder method. Use the value from the table below to specify the folder you want to create.

Application.GetNameSpace("MAPI").GetDefaultFolder(6)
Default folder | Has the value
Deleted Items | 3
Outbox | 4
Sent Items | 5
Inbox | 6
Calendar | 9
Contacts | 10
Journal | 11
Notes | 12
Tasks | 13


Creating a new item

To create a new item, use the CreateItem method of the Application object. This method returns an object that you can then use to work with the item.

The following Microsoft Visual Basic for Applications example shows how to create a mail message, add text to its subject and body, and display it. To use this sample, create a command button named Command1 on a form.

Private Sub Command1_Click()
    Dim myOLApp As New Outlook.Application
    Dim myOLItem As Outlook.MailItem
    Set myOLItem = myOLApp.CreateItem(olMailItem)
    With myOLItem
        .Subject = "Sample item"
        .Body = "This is a sample message."
    End With
    myOLItem.Display
End Sub

The following example shows how to perform the same task using VBScript in a form.

Sub CommandButton1_Click()
    Set myOLItem = Application.CreateItem(0)
    myOLItem.Subject = "Sample item"
    myOLItem.Body = "This is a sample message."
    myOLItem.Display
End Sub


Referencing existing items in a folder

There are a number of ways you can reference existing items in a folder using Microsoft Visual Basic. This topic provides information about:

  • Using a For … Next or For Each … Next loop

  • Using the Items collection

  • Using the Find method

  • Using the Restrict method

Using a For…Next or For Each...Next Loop

Typically these statements are used to loop through all of the items in a folder. The Items collection contains all the items in a particular folder, and you can specify which item to reference by using an index with the Items collection. This is typically used with the For I = 1 to n programming construct.

You can use For Each...Next to loop through the items in the collection without specifying an index. Both approaches achieve the same result.

The following examples use For…Next to loop through all the contacts in the Contacts folder and display the Full Name field in a dialog box.

' Visual Basic/Visual Basic for Applications code example.
Set ol = New Outlook.Application
Set olns = ol.GetNameSpace("MAPI")
' Set MyFolder to the default contacts folder.
Set MyFolder = olns.GetDefaultFolder(olFolderContacts)
' Get the number of items in the folder.
NumItems = MyFolder.Items.Count
' Set MyItem to the collection of items in the folder.
Set myItems = myFolder.Items.Restrict("[MessageClass] = 'IPM.Contact'")
' Loop through all of the items in the folder.
For I = 1 to NumItems
   MsgBox MyItems(I).FullName
Next

' VBScript code example.
Set olns = Item.Application.GetNameSpace("MAPI")
' Set MyFolder to the default contacts folder.
Set MyFolder = olns.GetDefaultFolder(10)
' Get the number of items in the folder.
NumItems = MyFolder.Items.Count
' Set MyItem to the collection of items in the folder.
Set myItems = myFolder.Items.Restrict("[MessageClass] = 'IPM.Contact'")
' Loop through all of the items in the folder.
For I = 1 to NumItems
   MsgBox MyItems(I).FullName
Next

The following examples use For Each...Next to achieve the same result as the preceding examples:

' Visual Basic/Visual Basic for Applications code example.
Set ol = New Outlook.Application
Set olns = ol.GetNameSpace("MAPI")
' Set MyFolder to the default contacts folder.
Set MyFolder = olns.GetDefaultFolder(olFolderContacts)
' Set MyItems to the collection of items in the folder.
Set myItems = myFolder.Items.Restrict("[MessageClass] = 'IPM.Contact'")
For Each SpecificItem in MyItems
   MsgBox SpecificItem.FullName
Next
' VBScript code example.
Set olns = Item.Application.GetNameSpace("MAPI")
' Set MyFolder to the default contacts folder.
Set MyFolder = olns.GetDefaultFolder(10)
' Set MyItem to the collection of items in the folder.
Set myItems = myFolder.Items.Restrict("[MessageClass] = 'IPM.Contact'")
For Each SpecificItem in MyItems
   MsgBox SpecificItem.FullName
Next

Using the Items Collection

You can also use the Items collection and specify a text string that matches the Subject field of an item. The following examples display an item in the Inbox whose subject contains "Please help on Friday!"

' Visual Basic/Visual Basic for Applications code example.
Set ol = New Outlook.Application
Set olns = ol.GetNameSpace("MAPI")
' Set MyFolder to the default Inbox.
Set MyFolder = olns.GetDefaultFolder(olFolderInbox)
Set MyItem = MyFolder.Items("Please help on Friday!")
MyItem.Display

' VBScript code example.
Set olns = Item.Application.GetNameSpace("MAPI")
' Set MyFolder to the default Inbox.
Set MyFolder = olns.GetDefaultFolder(6)
Set MyItem = MyFolder.Items("Please help on Friday!")
MyItem.Display

Using the Find Method

Use the Find method to search for an item in a folder based on the value of one of its fields. If the search is successful, you can then use the FindNext method to check for additional items that meet the same search criteria.

The following examples search to see if you have any high priority tasks.

' Visual Basic/Visual Basic for Applications code example.
Set ol = New Outlook.Application
Set olns = ol.GetNamespace("MAPI")
Set myFolder = olns.GetDefaultFolder(olFolderTasks)
Set MyTasks = myFolder.Items
' Importance corresponds to Priority on the task form.
Set MyTask = MyTasks.Find("[Importance] = ""High""")
If MyTask Is Nothing Then ' the Find failed
   MsgBox "Nothing important. Go party!"
Else
   MsgBox "You have something important to do!"
End If

' VBScript code example.
Set olns = Item.Application.GetNamespace("MAPI")
Set myFolder = olns.GetDefaultFolder(13)
Set MyTasks = myFolder.Items
' Importance corresponds to Priority on the task form.
Set MyTask = MyTasks.Find("[Importance] = ""High""")
If MyTask Is Nothing Then ' the Find failed
   MsgBox "Nothing important. Go party!"
Else
   MsgBox "You have something important to do!"
End If

Using the Restrict Method

The Restrict method is similar to the Find method, but instead of returning a single item, it returns a collection of items that meet the search criteria. For example, you could use this method to find all contacts that work at the same company.

The following examples display all of the contacts that work atProseWare Corporation:

' Automation code example.
Set ol = New Outlook.Application
Set olns = ol.GetNameSpace("MAPI")
Set MyFolder = olns.GetDefaultFolder(olFolderContacts)
Set myItems = myFolder.Items.Restrict("[MessageClass] = 'IPM.Contact'")
MyClause = "[CompanyName] = ""ProseWare"""
Set MyPWItems = MyItems.Restrict(MyClause)
For Each MyItem in MyPWItems
   MyItem.Display
Next

' VBScript code example.
Set olns = Item.Application.GetNameSpace("MAPI")
Set MyFolder = olns.GetDefaultFolder(10)
Set myItems = myFolder.Items.Restrict("[MessageClass] = 'IPM.Contact'")
MyClause = "[CompanyName] = ""ProseWare"""
Set MyPWItems = MyItems.Restrict(MyClause)
For Each MyItem in MyPWItems
   MyItem.Display
Next


Filtering items in a collection

You can use the Microsoft Outlook object model to return information about all items in a folder. Often, however, the desired objective is to search for a specific item or to retrieve a subset of the items in the folder. Consider the following examples:

  • You are developing a Microsoft Access database. When the user enters a new contact record, you want to give the user the ability to click a button to check whether a contact with the same name already exists in Outlook. If a match is found, you can retrieve all the fields for the contact and automatically fill in the Access database record. In this situation, if the user filled in the first and last name fields on the Access form, you can use the Find method in the Outlook object model to search for a match against the Outlook Full Name field. If you want to make sure there are no additional contacts in Outlook with the same name, you can then use the FindNext method to conduct the same search again.

  • You are writing a Microsoft Visual Basic program to automatically schedule appointments in users’ calendars. In order to do this, you need to retrieve a user’s appointments for a given day. In this case, you would use the Restrict method to retrieve all appointments that fall on a particular day.

While the Find and Restrict methods perform different functions, the syntax for both is similar. Following are some tips for using these methods:

  • The filters used with Find and Restrict are not case-sensitive.

  • It is not possible to use these methods if you need to search for a string that’s contained within an Outlook field, commonly called a "Contains" operation. If you need to perform a Contains operation, you can iterate through all of the items in the folder and use the Visual Basic InStr function to see if your search string is contained within an Outlook field.

  • To create a filter that performs a "begins with" operation, use the >, < , >=, and <= operators. For example, to search for all contacts whose last names begin with "Mc", use this filter: ""[LastName] >= ""Mc"" and [LastName] < ""Md"""

  • You can use the contents of a variable as part of the filter. For an example of this, see the Restrict Method Example.


Working with recurring appointments

When you create a recurring appointment in Microsoft Outlook, there is only one appointment item that represents all the occurrences of the appointment. This single appointment contains fields that specify details about how the appointment recurs. Note that when viewing your calendar, Outlook displays all the appointments as if they were separate items in the calendar.

By default, if you programmatically step through the items in the Calendar folder, only the first occurrence of a recurring appointment will be returned, since that’s the only item that actually exists. To retrieve all the appointments on the calendar, including the recurring appointments, use the IncludeRecurrences property. For information about retrieving or setting recurrence information, see the RecurrencePattern Object.


Working with recurring tasks

When you create a recurring task in Microsoft Outlook, there is only one task item that represents all the occurrences of the task. This single task contains fields that specify details about how the task recurs. Unlike recurring appointments, however, a recurring task doesn’t replicate in the views of the Task folder. Instead, when a recurring task is marked Complete, Outlook creates a new task item for the next occurrence.


Working with command bars

In Microsoft Outlook 2000, toolbars, menu bars, and shortcut menus are all controlled programmatically as one type of object: command bars. All the following items are represented in Microsoft Visual Basic by CommandBar objects:

  • Menu bars, toolbars, and shortcut menus

  • Menus on menu bars and toolbars

  • Submenus on menus, submenus, and shortcut menus

You can modify any built-in menu bar or toolbar, and you can create and modify custom toolbars, menu bars, and shortcut menus to deliver with your Visual Basic application. You can present the features of your application as buttons on toolbars or as groups of command names on menus. Because toolbars and menus are both command bars, you use the same kind of controls on both of them. Menu bars and toolbars can both contain menus.

In Visual Basic, buttons and menu items are represented by CommandBarButton objects. The pop-up controls that display menus and submenus are represented by CommandBarPopup objects.

You can also add text boxes, drop-down list boxes, and combo boxes to any command bar. These three types of controls are all represented in Visual Basic by CommandBarComboBox objects.

Note Although they share similar appearances and behaviors, command bar controls and ActiveX controls are not the same. You cannot add ActiveX controls to command bars, and you cannot add command bar controls to documents or forms.

The built-in command bar controls in Outlook are also represented by CommandBarButton, CommandBarPopup, and CommandBarComboBox objects, but their appearances and behaviors may be different from those you can add yourself. You can modify the location and appearance of built-in controls, you cannot modify their built-in behavior.

The following topics provide information about how you make changes to toolbars and menu bars from your Visual Basic code.

Adding and modifying toolbars

Adding and managing menu bars and menu items

Adding and displaying shortcut menus


 CheckBox control

CheckBox control

Displays the selection state of an item.

Remarks

Use a CheckBox to give the user a choice between two values such as Yes/No, True/False, or On/Off. When the user selects a CheckBox, it displays a special mark (such as an X) and its current setting is Yes, True, or On. If the user does not select the CheckBox, it is empty and its setting is No, False, or Off. Depending on the value of the TripleState property, a CheckBox can also have a null value.

If a CheckBox is bound to a data source, changing the setting changes the value of that source. A disabled CheckBox shows the current value, but is dimmed and does not allow changes to the value from the user interface.

You can also use check boxes inside a group box to select one or more of a group of related items. For example, you can create an order form that contains a list of available items, with a CheckBox preceding each item. The user can select a particular item or items by checking the corresponding CheckBox.

The default property of a CheckBox is the Value property.

Note The ListBox also lets you put a check mark by selected options. Depending on your application, you can use the ListBox instead of using a group of CheckBox controls.


 ComboBox control

ComboBox control

Combines the features of a ListBox and a TextBox. The user can enter a new value, as with a TextBox, or the user can select an existing value as with a ListBox.

Remarks

If a ComboBox is bound to a data source, the ComboBox inserts the value entered or selected by the user into that data source. If a multicolumn combo box is bound, then the BoundColumn property determines which value is stored in the bound data source.

The list in a ComboBox consists of rows of data. Each row can have one or more columns, which can appear with or without headings. Some applications do not support column headings, others provide only limited support.

The default property of a ComboBox is the Value property.

Note If you want more than a single line of the list to appear at all times, you might want to use a ListBox instead of a ComboBox. If you want to use a ComboBox and limit values to those in the list, you can set the Style property of the ComboBox so the control looks like a drop-down list box.


CommandButton control

Starts, ends, or interrupts an action or series of actions.

Remarks

Requires VBScript.

Syntax

Sub CommandButton_Click( )

'write event code here

End Sub

The macro or event procedure assigned to the CommandButton's Click event determines what the CommandButton does. For example, you can create a CommandButton that opens another form. You can also display text, a picture, or both on a CommandButton.

The default property of a CommandButton is the Value property.

The only event for a CommandButton is the Click event.


Font Object

Defines the characteristics of the text used by a control.

Each control has its own Font object to let you set its text characteristics independently of the characteristics defined for other controls. Use font properties to specify the font name, to set bold, italic, or underlined text, or to adjust the size of the text.

The default property for the Font object is the Name property.


 Frame control

Frame control

Creates a functional and visual control group.

Remarks

All option buttons in a Frame are mutually exclusive, so you can use the Frame to create an option group. You can also use a Frame to group controls with closely related contents.For example, in an application that processes customer orders, you might use a Frame to group the name, address, and account number of customers.

You can also use a Frame to create a group of ToggleButtons, but the toggle buttons are not mutually exclusive.

To create a group of mutually exclusive OptionButton controls, you can put the buttons in a Frameon your form, or you can use the GroupName property.


 Image control

Image control

Displays a picture on a form.

Remarks

The Image control lets you display a picture as part of the data in a form. For example, you might use an Image to display employee photographs in a personnel form.

The Image lets you crop, size, or zoom a picture, but does not allow you to edit the contents of the picture. For example, you cannot use the Image to change the colors in the picture, to make the picture transparent, or to refine the image of the picture. You must use image editing software for these purposes.

The Image supports the following file formats:

  • *.bmp

  • *.cur

  • *.gif

  • *.ico

  • *.jpg

  • *.wmf

Note You can also display a picture on a Label. However, a Label does not let you crop, size, or zoom the picture.<P>


Label control

Displays descriptive text.

Remarks

A Label control on a form displays descriptive text such as titles, captions, pictures, or brief instructions. For example, labels for an address book might include a Label for a name, street, or city.

The default property for a Label is the Caption property.

Note You can also display a picture on a Label. However, a Label does not let you crop, size, or zoom the picture.


 ListBox control

ListBox control

Displays a list of values and lets you select one or more.

Remarks

If the ListBox is bound to a data source, the ListBox stores the selected value in that data source.

The ListBox can either appear as a list or as a group of OptionButton controls or CheckBox controls.

The default property for a ListBox is the Value property.

The default event for a ListBox is the Click event.

Note You can't drop text into a drop-down ListBox.

ListBox styles

You can choose between two presentation styles for a ListBox. Each style provides different ways for users to select items in the list.

If the style is Plain, each item is on a separate row; the user selects an item by highlighting one or more rows.

If the style is Option, an OptionButton or CheckBox appears at the beginning of each row. With this style, the user selects an item by clicking the option button or check box. Check boxes appear only when the MultiSelect property is True.


 MultiPage control

MultiPage control

Presents multiple screens of information as a single set.

Remarks

A MultiPage is useful when you work with a large amount of information that can be sorted into several categories. For example, use a MultiPage to display information from an employment application. One page might contain personal information such as name and address; another page might list previous employers; a third page might list references. The MultiPage lets you visually combine related information, while keeping the entire record readily accessible.

New pages are added to the right of the currently selected page rather than adjacent to it.

A MultiPage is a control that contains a collection of one or more pages.

Each Page of a MultiPage is a form that contains its own controls, and as such, can have a unique layout. Typically, the pages in a MultiPage have tabs so the user can select the individual pages.

By default, a MultiPage includes two pages, called Page1 and Page2. Each of these is a Page object, and together they represent the Pages collection of the MultiPage. If you add more pages, they become part of the same Pages collection.

The default property for a MultiPage is the Value property, which returns the index of the currently active Page in the Pages collection of the MultiPage.

Note The MultiPage control does not support the Click event.


 OptionButton control

OptionButton control

Shows the selection status of one item in a group of choices.

Remarks

Use an OptionButton to show whether a single item in a group is selected. Note that each OptionButton in a Frame is mutually exclusive.

If an OptionButton is bound to a data source, the OptionButton can show the value of that data source as either Yes/No, True/False, or On/Off. If the user selects the OptionButton, the current setting is Yes, True, or On. If the user does not select the OptionButton, the setting is No, False, or Off. For example, an OptionButton in an inventory-tracking application might show whether an item is discontinued. If the OptionButton is bound to a data source, then changing the setting changes the value of that data source. A disabled OptionButton is dimmed and does not show a value.

Depending on the value of the TripleState property, an OptionButton can also have a null value.

You can also use an OptionButton inside a group box to select one or more of a group of related items. For example, you can create an order form with a list of available items, with an OptionButton preceding each item. The user can select a particular item by checking the corresponding OptionButton.

The default property for an OptionButton is the Value property.


Page Object

One page of a MultiPage or a single member of a Pages collection.

Remarks

Each Page object contains its own set of controls and does not necessarily rely on other pages in the collection for information. A Page inherits some properties from its container; the value of each inherited property is set by the container.

You can reference a Page by its index value. The index value reflects the ordinal position of the Page within the collection. The index of the first Page in a collection is 0; the index of the second Page is 1; and so on.

The default name for the first Page is Page1. The default name for the second Page is Page2.


ScrollBar control

Returns or sets the value of another control based on the position of the scroll box.

Remarks

Requires VBScript.

A ScrollBar is a stand-alone control you can place on a form. It is visually like the scroll bar you see in certain objects such as a ListBox or the drop-down portion of a ComboBox. However, unlike the scroll bars in these controls, the stand-alone ScrollBar is not an integral part of any other control.

To use the ScrollBar to set or read the value of another control, you must write code that uses the ScrollBar's Value property. For example, to use the ScrollBar to update the value of a TextBox, you can write code that reads the Value property of the ScrollBar and then sets the Value property of the TextBox.

The default property for a ScrollBar is the Value property.

Note To create a horizontal or vertical ScrollBar, drag the sizing handles of the ScrollBar horizontally or vertically on the form.


SpinButton control

Increments and decrements numbers.

Remarks

Requires VBScript.

Clicking a SpinButton changes only the value of the SpinButton. You can write code that uses the SpinButton to update the displayed value of another control. For example, you can use a SpinButton to change the month, the day, or the year shown on a date. You can also use a SpinButton to scroll through a range of values or a list of items, or to change the value displayed in a text box.

To display a value updated by a SpinButton, you must assign the value of the SpinButton to the displayed portion of a control, such as the Caption property of a Label or the Text property of a TextBox. To create a horizontal or vertical SpinButton, drag the sizing handles of the SpinButton horizontally or vertically on the form.

The default property for a SpinButton is the Value property.


Tab Object

A Tab is an individual member of a Tabs collection.

Remarks

Visually, a Tab object appears as a rectangle protruding from a larger rectangular area, or as a button adjacent to a rectangular area.

In contrast to a Page, a Tab does not contain any controls. Controls that appear within the region bounded by a TabStrip are contained on the form, as is the TabStrip.

You can reference a Tab by its index value. The index value reflects the ordinal position of the Tab within the collection. The index of the first Tab in a collection is 0; the index of the second Tab is 1; and so on.


 TabStrip control

TabStrip control

Presents a set of related controls as a visual group.

Remarks

You can use a TabStrip to view different sets of information for related controls.

A TabStrip is a control that contains a collection of one or more tabs.

Each Tab of a TabStrip is a separate object that users can select. Visually, a TabStrip also includes a client area that all the tabs in the TabStrip share.

By default, a TabStrip includes two pages, called Tab1 and Tab2. Each of these is a Tab object, and together they represent the Tabs collection of the TabStrip. If you add more pages, they become part of the same Tabs collection.

For example, the controls might represent information about a daily schedule for a group of individuals, with each set of information corresponding to a different individual in the group. Set the title of each tab to show one individual's name. Then, you can write code that, after you click a tab, updates the controls to show information about the person identified on the tab.

Note The TabStrip is implemented as a container of a Tabs collection, which in turn contains a group of Tab objects. The TabStrip control does not support the Click event.

The default property for a TabStrip is the SelectedItem property.


 TextBox control

TextBox control

Displays information from a user or from an organized set of data.

Remarks

A TextBox is the control most commonly used to display information entered by a user. Also, it can display a set of data, such as a table, query, worksheet, or a calculation result. If a TextBox is bound to a data source, then changing the contents of the TextBox also changes the value of the bound data source.

Formatting applied to any piece of text in a TextBox will affect all text in the control. For example, if you change the font or point size of any character in the control, the change will affect all characters in the control.

The default property for a TextBox is the Value property.

Tips on using text boxes

The TextBox is a flexible control governed by the following properties: Text, MultiLine, WordWrap, and AutoSize.

Text contains the text that's displayed in the text box.

MultiLine controls whether the TextBox can display text as a single line or as multiple lines. Newline characters identify where one line ends and another begins. If MultiLine is False (the default value), the text is truncated instead of wrapped.

WordWrap allows the TextBox to wrap lines of text that are longer than the width of the TextBox into shorter lines that fit. The default value is True.

If you do not use WordWrap, the TextBox starts a new line of text when it encounters a newline character in the text. If WordWrap is turned off, you can have text lines that do not fit completely in the TextBox. The TextBox displays the portions of text that fit inside its width and truncates the portions of text that do not fit. WordWrap is not applicable unless MultiLine is True.

AutoSize controls whether the TextBox adjusts to display all of the text. When using AutoSize with a TextBox, the width of the TextBox shrinks or expands according to the amount of text in the TextBox and the font size used to display the text. The default value is False.

AutoSize works well in the following situations:

  • Displaying a caption of one or more lines.

  • Displaying the contents of a single-line TextBox.

  • Displaying the contents of a multiline TextBox that is read-only to the user.

Note Avoid using AutoSize with an empty TextBox that also uses the MultiLine and WordWrap properties. When the user enters text into a TextBox with these properties, the TextBox automatically sizes to a long narrow box one character wide and as long as the line of text.


 ToggleButton control

ToggleButton control

Shows the selection state of an item.

Remarks

Use a ToggleButton to show whether an item is selected. If a ToggleButton is bound to a data source, the ToggleButton shows the current value of that data source as either Yes/No, True/False, On/Off, or some other choice of two settings. If the user selects the ToggleButton, the current setting is Yes, True, or On. If the user does not select the ToggleButton, the setting is No, False, or Off. If the ToggleButton is bound to a data source, changing the setting changes the value of that data source. A disabled ToggleButton shows a value, but is dimmed and does not allow changes from the user interface.

You can also use a ToggleButton inside a Frame to select one or more of a group of related items. For example, you can create an order form with a list of available items, with a ToggleButton preceding each item. The user can select a particular item by selecting the appropriate ToggleButton.

The default property of a ToggleButton is the Value property.

The only event for a ToggleButton is the Click event.


 Click Event

Click Event

The Click event occurs only if it has been defined for a control in the Script Editor.

The TabStrip and MultiPage controls do not support the Click event. However, individual the Page objects of the MultiPage control do support the click event.

ScrollBars and SpinButtons do not support the Click event but you can bind them to fields and use the CustomPropertyChange event.

The Click event occurs in one of two cases:

  • The user clicks a control with the mouse.

  • The user definitively selects a value for a control with more than one possible value.

Syntax

Sub object_Click( )

The Click event syntax has these parts:

Part | Description
object | Required. A valid object.

Example:

Sub CommandButton1_Click()
    MsgBox "You just clicked my button! "
End Sub

Remarks

Of the two cases where the Click event occurs, the first case applies to the CommandButton, Frame, Image Label, and Page.

The second case applies to the CheckBox, ComboBox, ListBox, and ToggleButton. It also applies to an OptionButton when the value changes to True.

The following are examples of actions that initiate the Click event:

  • Clicking a blank area of a form or a disabled control (other than a list box) on the form.

  • Clicking a CommandButton.

  • Pressing the SPACEBAR when a CommandButton has the focus.

  • Clicking a control with the left mouse button (left-clicking).

  • Pressing ENTER on a form that has a command button whose Default property is set to True, as long as no other command button has the focus.

  • Pressing ESC on a form that has a command button whose Cancel property is set to True, as long as no other command button has the focus.

  • Pressing a control's accelerator key.

For some controls, the Click event occurs when the Value property changes. However, using the PropertyChange or CustomPropertyChange event is the preferred technique for detecting a new value for a property. The following are examples of actions that initiate the Click event due to assigning a new value to a control:

  • Clicking a CheckBox or ToggleButton, pressing the SPACEBAR when one of these controls has the focus, pressing the accelerator key for one of these controls, or changing the value of the control in code.

  • Changing the value of an OptionButton to True. Setting one OptionButton in a group to True sets all other buttons in the group to False, but the Click event occurs only for the button whose value changes to True.

  • Selecting a value for a ComboBox or ListBox so that it unquestionably matches an item in the control's drop-down list. For example, if a list is not sorted, the first match for characters typed in the edit region may not be the only match in the list, so choosing such a value does not initiate the Click event. In a sorted list, you can use entry-matching to ensure that a selected value is a unique match for text the user types.

The Click event is not initiated when Value is set to Null.

Note Left-clicking changes the value of a control, thus it initiates the Click event. Right-clicking does not change the value of the control, so it does not initiate the Click event.

Also Note If you bind a ListBox, ComboBox, OptionButton, or CheckBox to a field, then the Click event does not fire. You need to use the PropertyChange or CustomPropertyChange event to detect the change via code.

Example:

Sub Item_PropertyChange(ByVal Name)
Set MyListBox = Item.GetInspector.ModifiedFormPages("Message").Controls("ListBox1")
Select Case Name
    Case "Mileage"
        Item.CC = MyListBox.Value
        Item.Subject = MyListBox.Value
    Case Else
End Select
End Sub


 Add Method

Add Method

Adds a control by its programmatic identifier (ProgID) to a page or adds or inserts a Tab or Page in a TabStrip or MultiPage.

Syntax

For MultiPage, TabStrip
Set Object = object.Add( [ Name [, Caption [, index]]])

For other controls
Set Control = object.Add( ProgID [, Name [, Visible]])

The Add method syntax has these parts:

Part | Description
object | Required. A valid object name.
Name | Optional. Specifies the name of the object being added. If a name is not specified, the system generates a default name based on the rules of the application where the form is used.
Caption | Optional. Specifies the caption to appear on a tab or a control. If a caption is not specified, the system generates a default caption based on the rules of the application where the form is used.
index | Optional. Identifies the position of a page or tab within a Pages or Tabs collection. If an index is not specified, the system appends the page or tab to the end of the Pages or Tabs collection and assigns the appropriate index value.
ProgID | Required. Programmatic identifier. A text string with no spaces that identifies an object class. The standard syntax for a ProgID is <Vendor>.<Component>.<Version>. A ProgID is mapped to a class identifier (CLSID).
Visible | Optional. True if the object is visible (default). False if the object is hidden.

Settings

ProgID values for individual controls are:

CheckBox

Forms.CheckBox.1
ComboBox | Forms.ComboBox.1
CommandButton | Forms.CommandButton.1
Frame | Forms.Frame.1
Image | Forms.Image.1
Label | Forms.Label.1
ListBox | Forms.ListBox.1
MultiPage | Forms.MultiPage.1
OptionButton | Forms.OptionButton.1
ScrollBar | Forms.ScrollBar.1
SpinButton | Forms.SpinButton.1
TabStrip | Forms.TabStrip.1
TextBox | Forms.TextBox.1
ToggleButton | Forms.ToggleButton.1

Remarks

For a MultiPage control, the Add method returns a Page object. For a TabStrip, it returns a Tab object. The index value for the first Page or Tab of a collection is 0, the value for the second Page or Tab is 1, and so on.

For the Controls collection of an object, the Add method returns a control corresponding to the specified ProgID. The AddControl event occurs after the control is added.

The following syntax will return the Text property of a control added at design time:

userform1.thebox.text

If you add a control at run time, you must use the exclamation syntax to reference properties of that control. For example, to return the Text property of a control added at run time, use the following syntax:

userform1!thebox.text

Note You can change a control's Name property at run time only if you added that control at run time with the Add method.


 AddItem Method

AddItem Method

For a single-column ListBox or ComboBox, the AddItem method adds an item to the list. For a multicolumn ListBox or ComboBox, this method adds a row to the list.

Syntax

Variant = object.AddItem( [ item [, varIndex]])

The AddItem method syntax has these parts:

Part | Description
object | Required. A valid object.
Item | Optional. Specifies the item or row to add. The number of the first item or row is 0; the number of the second item or row is 1, and so on.
varIndex | Optional. Integer specifying the position within the object where the new item or row is placed.

Remarks

If you supply a valid value for varIndex, the AddItem method places the item or row at that position within the list. If you omit varIndex, the method adds the item or row at the end of the list.

The value of varIndex must not be greater than the value of the ListCount property.

For a multicolumn ListBox or ComboBox, AddItem inserts an entire row, that is, it inserts an item for each column of the control. To assign values to an item beyond the first column, use the List or Column property and specify the row and column of the item.

If the control is bound to data, the AddItem method fails.

Note You can add more than one row at a time to a ComboBox or ListBox by using List.


 Clear Method

Clear Method

Removes all objects from an object or collection.

Syntax

object.Clear

The Clear method syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

For a MultiPage or TabStrip, the Clear method deletes individual pages or tabs.

For a ListBox or ComboBox, Clear removes all entries in the list.

For a Controls collection, Clear deletes controls that were created at run-time with the Add method. Using Clear on controls created at design-time causes an error.

Note If the control is bound to data, the Clear method fails.


Copy Method

Copies the contents of an object to the Clipboard.

Syntax

object.Copy

The Copy method syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

The original content remains on the object.

The actual content that is copied depends on the object. For example, on a Page, the Copy method copies the currently selected control or controls. On a TextBox or ComboBox, it copies the currently selected text.

Using Copy for a form, Frame, or Page copies the currently-active control.


 Cut Method

Cut Method

Removes selected information from an object and transfers it to the Clipboard.

Syntax

object.Cut

The Cut method syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

For a ComboBox or TextBox, the Cut method removes currently selected text in the control to the Clipboard. This method does not require that the control have the focus.

On a Page, Frame, or form, Cut removes currently selected controls to the Clipboard. This method only removes controls created at run time.


DropDown Method

Displays the list portion of a ComboBox.

Syntax

object.DropDown

The DropDown method syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

Use the DropDown method to open the list in a combo box.


 GetFormat Method

GetFormat Method

Returns an integer value indicating whether a specific format is on the DataObject.

Syntax

Boolean = object.GetFormat( format)

The GetFormat method syntax has these parts:

Part | Description
object | Required. A valid object.
format | Required. An integer or string specifying a specific format that might exist in the DataObject. If the specified format exists in the DataObject, GetFormat returns True.

Settings

The settings for format are:

Value | Description
1 | Text format.
A string or any integer other than 1 | A user-defined DataObject format passed to the DataObject from SetText.

Remarks

The GetFormat method searches for a format in the current list of formats on the DataObject. If the format is on the DataObject, GetFormat returns True; if not, GetFormat returns False.

The DataObject currently supports only text formats.


GetFromClipboard Method

Copies data from the Clipboard to a DataObject.

Syntax

String = object.GetFromClipboard( )

The GetFromClipboard method syntax has these parts:

Part | Description
object | Required. A valid object name.

Remarks

The DataObject can contain multiple data items, but each item must be in a different format. For example, the DataObject might include one text item and one item in a custom format; but cannot include two text items.


 GetText Method

GetText Method

Retrieves a text string from the DataObject using the specified format.

Syntax

String = object.GetText( [ format])

The GetText method syntax has these parts:

Part | Description
object | Required. A valid object name.
format | Optional. A string or integer specifying the format of the data to retrieve from the DataObject.

Settings

The settings for format are:

Value | Description
1 | Text format.
A string or any integer other than 1 | A user-defined DataObject format passed to the DataObject from SetText.

Remarks

The DataObject supports multiple formats, but only supports one data item of each format. For example, the DataObject might include one text item and one item in a custom format; but cannot include two text items.

If no format is specified, the GetText method requests information in the Text format from the DataObject.


 Item Method

Item Method

Returns a member of a collection, either by position or by name.

Syntax

Set Object = object.Item( collectionindex)

The Item method syntax has these parts:

Part | Description
object | Required. A valid object.
collectionindex | Required. A member's position, or index, within a collection.

Settings

The collectionindex can be either a string or an integer. If it is a string, it must be a valid member name. If it is an integer, the minimum value is 0 and the maximum value is one less than the number of items in the collection.

Remarks

If an invalid index or name is specified, an error occurs.


Move Method

Moves a form or control, or moves all the controls in the Controls collection..

Syntax

For a form or control
object.Move( [Left [, Top [, Width [, Height [, Layout]]]]])

For the Controls collection
object.Move( X, Y)

The Move method syntax has these parts:

Part | Description
object | Required. A valid object name.
Left | Optional. Single-precision value, in points, indicating the horizontal coordinate for the left edge of the object.
Top | Optional. Single-precision value, in points, that specifies the vertical coordinate for the top edge of the object.
Width | Optional. Single-precision value, in points, indicating the width of the object.
Height | Optional. Single-precision value, in points, indicating the height of the object.
Layout | Optional. A Boolean value indicating whether the Layout event is initiated for the control's parent following this move. False is the default value.
X, Y | Required. Single-precision value, in points, that specifies the change from the current horizontal and vertical position for each control in the Controls collection.

Settings

The maximum and minimum values for the Left, Top, Width, Height, X, and Y arguments vary from one application to another.

Remarks

For a form or control, you can move a selection to a specific location relative to the edges of the form that contains the selection.

You can use named arguments, or you can enter the arguments by position. If you use named arguments, you can list the arguments in any order. If not, you must enter the arguments in the order shown, using commas to indicate the relative position of arguments you do not specify. Any unspecified arguments remain unchanged.

For the Controls collection, you can move all the controls in this collection a specific distance from their current positions on a Frame or Page.


Paste Method

Transfers the contents of the Clipboard to an object.

Syntax

object.Paste

The Paste method syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

Data pasted into a ComboBox or TextBox is treated as text.


PutInClipboard Method

Moves data from a DataObject to the Clipboard.

Syntax

object.PutInClipboard

The PutInClipboard method syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

The PutInClipboard method replaces the contents of the Clipboard with the contents of the DataObject that is in Text format.


RedoAction Method

Reverses the effect of the most recent Undo action.

Syntax

Boolean = object.RedoAction

The RedoAction method syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

Redo reverses the last Undo, which is not necessarily the last action taken. Not all actions can be undone.

RedoAction returns True if it was successful.


 Remove Method

Remove Method

Removes a member from a collection; or, removes a control from a Frame, or Page.

Syntax

object.Remove( collectionindex)

The Remove method syntax has these parts:

Part | Description
object | Required. A valid object.
collectionindex | Required. A member's position, or index, within a collection. Numeric as well as string values are acceptable. If the value is a number, the minimum value is zero, and the maximum value is one less than the number of members in the collection. If the value is a string, it must correspond to a valid member name.


 RemoveItem Method

RemoveItem Method

Removes a row from the list in a list box or combo box.

Syntax

Boolean = object.RemoveItem( index)

The RemoveItem method syntax has these parts:

Part | Description
object | Required. A valid object.
index | Required. Specifies the row to delete. The number of the first row is 0; the number of the second row is 1, and so on.

This method will not remove a row from the list if the ListBox is data bound (that is, when the RowSource property specifies a data source for the ListBox).


Repaint Method

Updates the display by redrawing the frame or page.

Syntax

Boolean = object.Repaint

The Repaint method syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

The Repaint method is useful if the contents or appearance of an object changes significantly, and you don't want to wait until the system automatically repaints the area.


Scroll Method

Moves the scroll bar on an object.

Syntax

object.Scroll( [ ActionX [, ActionY]])

The Scroll method syntax has these parts:

Part | Description
object | Required. A valid object name.
ActionX | Optional. Identifies the action to occur in the horizontal direction.
ActionY | Optional. Identifies the action to occur in the vertical direction.

Settings

The settings for ActionX and ActionY are:

Value | Description
0 | Do not scroll in the specified direction.
1 | Move up on a vertical scroll bar or left on a horizontal scroll bar. Movement is equivalent to pressing the up or left arrow key on the keyboard to move the scroll bar.
2 | Move down on a vertical scroll bar or right on a horizontal scroll bar. Movement is equivalent to pressing the right or down arrow key on the keyboard to move the scroll bar.
3 | Move one pageup on a vertical scroll bar or one page left on a horizontal scroll bar. Movement is equivalent to pressing PAGE UP on the keyboard to move the scroll bar.
4 | Move one pagedown on a vertical scroll bar or one page right on a horizontal scroll bar. Movement is equivalent to pressing PAGE DOWN on the keyboard to move the scroll bar.
5 | Move to the top of a vertical scroll bar or to the left end of a horizontal scroll bar.
6 | Move to the bottom of a vertical scroll bar or to the right end of a horizontal scroll bar.

Remarks

The Scroll method applies scroll bars that appear on a form, Frame, or Page that is larger than its display area. This method does not apply to the stand-alone ScrollBar or to scroll bars that appear on a TextBox.


 SetDefaultTabOrder Method

SetDefaultTabOrder Method

Sets the TabIndex property of each control on a frame or page, using a default top-to-bottom, left-to-right tab order.

Syntax

object.SetDefaultTabOrder

The SetDefaultTabOrder method syntax has these parts:

Part | Description
object | Required. A valid object.


 SetFocus Method

SetFocus Method

Moves the focus to this instance of an object.

Syntax

object.SetFocus

The SetFocus method syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

If setting the focus fails, the focus reverts to the previous object and an error is generated.

By default, setting the focus to a control does not activate the control's window or place it on top of other controls.

The SetFocus method is valid for an empty Frame as well as a Frame that contains other controls. An empty Frame will take the focus itself, and any subsequent keyboard events apply to the Frame. In a Frame that contains other controls, the focus moves to the first control in the Frame, and subsequent keyboard events apply to the control that has the focus.


 SetText Method

SetText Method

Copies a text string to the DataObject using a specified format.

Syntax

object.SetText( StoreData [, format])

The SetText method syntax has these parts:

Part | Description
object | Required. A valid object.
StoreData | Required. Defines the data to store on the DataObject.
format | Optional. An integer or string specifying the format of StoreData. When retrieving data from the DataObject, the format identifies the piece of data to retrieve.

Settings

The settings for format are:

Value | Description
1 | Text format.
A string or integer value other than 1 | A user-defined DataObject format.

Remarks

The DataObject stores data according to its format. When the user supplies a string, the DataObject saves the text under the specified format.

If the DataObject contains data in the same format as new data, the new data replaces the existing data in the DataObject. If the new data is in a new format, the new data and the new format are both added to the DataObject, and the previously existing data is there as well.

If no format is specified, the SetText method assigns the Text format to the text string. If a new format is specified, the DataObject registers the new format with the system.


StartDrag Method

Initiates a drag-and-drop operation for a DataObject.

Syntax

DropEffect=Object.StartDrag([Effect as DropEffect])

The StartDrag method syntax has these parts:

Part | Description
Object | Required. A valid object.
Effect | Optional. Effect of the drop operation on the target control.

Settings

The settings for Effect are:

Value | Description
0 | Does not copy or move the drop source to the drop target.
1 | Copies the drop source to the drop target.
2 | Moves the drop source to the drop target.
3 | Copies or moves the drop source to the drop target.

Remarks

The drag action starts at the current mouse pointer position with the current keyboard state and ends when the user releases the mouse. The effect of the drag-and-drop operation depends on the effect chosen for the drop target.

For example, a control's MouseMove event might include the StartDrag method. When the user clicks the control and moves the mouse, the mouse pointer changes to indicate whether Effect is valid for the drop target.


UndoAction Method

Reverses the most recent action that supports the Undo command.

Syntax

Boolean = object.UndoAction

The UndoAction method syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

Not all user actions can be undone. If an action cannot be undone, the Undo command is unavailable following the action.

You must apply this method before the form or control is updated. You may want to include this method in a form's PropertyChange event.


 ZOrder Method

ZOrder Method

Places the object at the front or back of the z-order.

Syntax

object.ZOrder( [ zPosition])

The ZOrder method syntax has these parts:

Part | Description
object | Required. A valid object.
zPosition | Optional. A control's position, front or back, in the container's z-order.

Settings

The settings for zPosition are:

Value | Description
0 | Places the control at the front of the z-order. The control appears on top of other controls (default).
1 | Places the control at the back of the z-order. The control appears underneath other controls.

Remarks

The z-order determines how windows and controls are stacked when they are presented to the user. Items at the back of the z-order are overlaid by closer items; items at the front of the z-order appear to be on top of items at the back. When the zPosition argument is omitted, the object is brought to the front.

In design mode, the Bring to Front or Send To Back commands set the z-order. Bring to Front is equivalent to using the ZOrder method and putting the object at the front of the z-order. Send to Back is equivalent to using ZOrder and putting the object at the back of the z-order.

This method does not affect content or sequence of the controls in the Controls collection.

Note You can't Undo or Redo layering commands, such as Send to Back or Bring to Front. For example, if you select an object and click Move Backward on the shortcut menu, you won't be able to Undo or Redo that action.


 Accelerator Property

Accelerator Property

Sets or retrieves the accelerator key for a control.

Syntax

object.Accelerator [= String]

The Accelerator property syntax has these parts:

Part | Description
object | Required. A valid object.
String | Optional. The character to use as the accelerator key.

Remarks

To designate an accelerator key, enter a single character for the Accelerator property. You can set Accelerator in the control's property sheet or in code. If the value of this property contains more than one character, the first character in the string becomes the value of Accelerator.

When an accelerator key is used, there is no visual feedback (other than focus) to indicate that the control initiated the Click event. For example, if the accelerator key applies to a CommandButton, the user will not see the button pressed in the interface. The button receives the focus, however, when the user presses the accelerator key.


ActiveControl Property

Identifies and allows manipulation of the control that has the focus.

Syntax

object.ActiveControl

The ActiveControl property syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

The ActiveControl property is read-only and is set when you select a control in the interface. You can use ActiveControl as a substitute for the control name when setting properties or calling methods.


Alignment Property

Specifies the position of a control relative to its caption.

Syntax

object.Alignment [= 0,1]

The Alignment property syntax has these parts:

Part | Description
object | Required. A valid object.

Settings

The Settings for Alignment are:

Value | Description
0 | Places the caption to the left of the control.
1 | Places the caption to the right of the control (default).

Remarks

The caption text for a control is left-aligned.


AutoSize Property

Specifies whether an object automatically resizes to display its entire contents.

Syntax

object.AutoSize [= Boolean]

The AutoSize property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the control is resized.

Settings

The settings for Boolean are:

Value | Description
True | Automatically resizes the control to display its entire contents.
False | Keeps the size of the control constant. Contents are clipped when they exceed the area of the control (default).

Remarks

For controls with captions, the AutoSize property specifies whether the control automatically adjusts to display the entire caption.

For controls without captions, this property specifies whether the control automatically adjusts to display the information stored in the control. In a ComboBox, for example, setting AutoSize to True automatically sets the width of the display area to match the length of the current text.

For a single-line TextBox, setting AutoSize to True automatically sets the width of the display area to the length of the text in the text box.

For a multiline TextBox that contains no text, setting AutoSize to True automatically displays the text as a column. The width of the text column is set to accommodate the widest letter of that font size. The height of the text column is set to display the entire text of the TextBox.

For a multiline TextBox that contains text, setting AutoSize to True automatically enlarges the TextBox vertically to display the entire text. The width of the TextBox does not change.

Note If you manually change the size of a control while AutoSize is True, the manual change overrides the size previously set by AutoSize.


 AutoTab Property

AutoTab Property

Specifies whether an automatic tab occurs when a user enters the maximum allowable number of characters into a TextBox or the text box portion of a ComboBox.

Syntax

object.AutoTab [= Boolean]

The AutoTab property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Specifies whether an automatic tab occurs.

Settings

The settings for Boolean are:

Value | Description
True | Tab occurs.
False | Tab does not occur (default).

Remarks

The MaxLength property specifies the maximum number of characters allowed in a TextBox or the text box portion of a ComboBox.

You can specify the AutoTab property for a TextBox or ComboBox on a form for which you usually enter a set number of characters. Once a user enters the maximum number of characters, the focus automatically moves to the next control in the tab order. For example, if a TextBox displays inventory stock numbers that are always five characters long, you can use MaxLength to specify the maximum number of characters to enter into the TextBox and AutoTab to automatically tab to the next control after the user enters five characters.


AutoWordSelect Property

Specifies whether the basic unit used to extend a selection is a word or a single character.

Syntax

object.AutoWordSelect [= Boolean]

The AutoWordSelect property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Specifies the basic unit used to extend a selection.

Settings

The settings for Boolean are:

Value | Description
True | Uses a word as the basic unit (default).
False | Uses a character as the basic unit.

Remarks

The AutoWordSelect property specifies how the selection extends or contracts in the edit region of a TextBox or ComboBox.

If the user places the insertion point in the middle of a word and then extends the selection while AutoWordSelect is True, the selection includes the entire word.


 BackColor Property

BackColor Property

Specifies the background color of the object.

Syntax

object.BackColor [= Long]

The BackColor property syntax has these parts:

Part | Description
object | Required. A valid object.
Long | Optional. A value or constant that determines the background color of an object.

Settings

You can use any integer that represents a valid color. You can also specify a color by using the RGB function with red, green, and blue color components. The value of each color component is an integer that ranges from zero to 255. For example, you can specify teal blue as the integer value 4966415 or as red, green, and blue color components 15, 200, 75, as shown in the following example.

RGB(15,200,75)

Remarks

You can only see the background color of an object if the BackStyle property is set to 1.


 BackStyle Property

BackStyle Property

Returns or sets the background style for an object.

Syntax

object.BackStyle [=BackStyle]

The BackStyle property syntax has these parts:

Part | Description
object | Required. A valid object.
BackStyle | Optional. Specifies the control background.

Settings

The settings for BackStyle are:

Value | Description
0 | The background is transparent.
1 | The background is opaque (default).

Remarks

The BackStyle property determines whether a control is transparent. If BackStyle is 1, the control is not transparent and you cannot see anything behind the control on a form. If BackStyle is 0, you can see through the control and look at anything on the form located behind the control. The BackColor property is only valid if the BackStyle property is set to 1.

Note BackStyle does not affect the transparency of bitmaps. You must use a picture editor such as Paintbrush to make a bitmap transparent. Not all controls support transparent bitmaps.


 Bold, Italic, Size, StrikeThrough, Underline, Weight Properties

Bold, Italic, Size, StrikeThrough, Underline, Weight Properties

Specifies the visual attributes of text on a displayed or printed form.

Syntax

object.Bold [= Boolean]

object.Italic [= Boolean]

object.Size [= Currency]

object.StrikeThrough [= Boolean]

object.Underline [= Boolean]

object.Weight [= Integer]

The Bold, Italic, Size, StrikeThrough, Underline, and Weight property syntaxes have these parts:

Part | Description
object | Required. A valid object name.
Boolean | Optional. Specifies the font style.
Currency | Optional. A number indicating the font size.
Integer | Optional. Specifies the font style.

The settings for Boolean are:

Value | Description
True | The text has the specified attribute (that is bold, italic, size, strikethrough or underline marks, or weight).
False | The text does not have the specified attribute (default).

The Weight property accepts values from 0 to 1000. A value of zero allows the system to pick the most appropriate weight. A value from 1 to 1000 indicates a specific weight, where 1 represents the lightest type and 1000 represents the darkest type.

Remarks

These properties define the visual characteristics of text. The Bold property determines whether text is normal or bold. The Italic property determines whether text is normal or italic. The Size property determines the height, in points, of displayed text. The Underline property determines whether text is underlined. The StrikeThrough property determines whether the text appears with strikethrough marks. The Weight property determines the darkness of the type.

The font's appearance on screen and in print may differ, depending on your computer and printer. If you select a font that your system can't display with the specified attribute or that isn't installed, Windows substitutes a similar font. The substitute font will be as similar as possible to the font originally requested.

Changing the value of Bold also changes the value of Weight. Setting Bold to True sets Weight to 700; setting Bold to False sets Weight to 400. Conversely, setting Weight to anything over 550 sets Bold to True; setting Weight to 550 or less sets Bold to False.

The default point size is determined by the operating system.


 BorderColor Property

BorderColor Property

Specifies the color of an object's border.

Syntax

object.BorderColor [= Long]

The BorderColor property syntax has these parts:

Part | Description
object | Required. A valid object.
Long | Optional. A value that determines the border color of an object.

Settings

You can use any integer that represents a valid color. You can also specify a color by using the RGB function with red, green, and blue color components. The value of each color component is an integer that ranges from zero to 255. For example, you can specify teal blue as the integer value 4966415 or as red, green, and blue color components 15, 200, 75, as shown in the following example.

RGB(15,200,75)

Remarks

To use the BorderColor property, the BorderStyle property must be set to a value other than 0.

BorderStyle uses BorderColor to define the border colors. The SpecialEffect property uses system colors exclusively to define its border colors. For Windows operating systems, system color settings are set using the Display icon in Control Panel. In Windows NT 3.51, system color settings are set using the Color icon in Control Panel.


BorderStyle Property

Specifies the type of border used by a control or a form.

Syntax

object.BorderStyle [=BorderStyle]

The BorderStyle property syntax has these parts:

Part | Description
object | Required. A valid object.
BorderStyle | Optional. Specifies the border style.

Settings

The settings for BorderStyle are:

Value | Description
0 | The control has no visible border line.
1 | The control has a single-line border (default).

The default value for a ComboBox, Frame, Label, ListBox or TextBox is 0 (None). The default value for an Image is 1 (Single).

Remarks

For a Frame, the BorderStyle property is ignored if the SpecialEffect property is None.

You can use either BorderStyle or SpecialEffect to specify the border for a control, but not both. If you specify a nonzero value for one of these properties, the system sets the value of the other property to zero. For example, if you set BorderStyle to 1, the system sets SpecialEffect to zero (Flat). If you specify a nonzero value for SpecialEffect, the system sets BorderStyle to zero.

BorderStyle uses BorderColor to define the colors of its borders. To use the BorderColor property, the BorderStyle property must be set to a value other than 0.


 BoundColumn Property

BoundColumn Property

Identifies the source of data in a multicolumn ComboBox or ListBox.

Syntax

object.BoundColumn [= Variant]

The BoundColumn property syntax has these parts:

Part | Description
object | Required. A valid object.
Variant | Optional. Indicates how the BoundColumn value is selected.

Settings

The settings for Variant are:

Value | Description
0 | Assigns the value of the ListIndex property to the control.
1 or greater | Assigns the value from the specified column to the control. Columns are numbered from 1 when using this property (default).

Remarks

When the user chooses a row in a multicolumn ListBox or ComboBox, the BoundColumn property identifies which item from that row to store as the value of the control. For example, if each row contains 8 items and BoundColumn is 3, the system stores the information in the third column of the currently-selected row as the value of the object.

You can display one set of data to users but store different, associated values for the object by using the BoundColumn and the TextColumn properties. TextColumn identifies the column of data displayed in a ComboBox or ListBox; BoundColumn identifies the column of associated data values stored for the control. For example, you could set up a multicolumn ListBox that contains the names of holidays in one column and dates for the holidays in a second column. To present the holiday names to users, specify the first column as the TextColumn. To store the dates of the holidays, specify the second column as the BoundColumn.

If the control is bound to a data source, the value in the column specified by BoundColumn is stored in the data source named in the ControlSource property.

The ListIndex value retrieves the number of the selected row. For example, if you want to know the row of the selected item, set BoundColumn to 0 to assign the number of the selected row as the value of the control. Be sure to retrieve a current value, rather than relying on a previously saved value, if you are referencing a list whose contents might change.

The Column, List, and ListIndex properties all use zero-based numbering. That is, the value of the first item (column or row) is zero; the value of the second item is one, and so on. This means that if BoundColumn is set to 3, you could access the value stored in that column using the expression Column(2).


 Cancel Property

Cancel Property

Returns or sets a value indicating whether a CommandButton is the Cancel button on a form.

Syntax

object.Cancel [= Boolean]

The Cancel property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the object is the Cancel button.

Settings

The settings for Boolean are:

Value | Description
True | The CommandButton is the Cancel button.
False | The CommandButton is not the Cancel button (default).

Remarks

A CommandButton or an object that acts like a command button can be designated as the default command button. For OLE container controls, the Cancel property is provided only for those objects that specifically behave as command buttons.

Only one CommandButton on a form can be the Cancel button. Setting Cancel to True for one command button automatically sets it to False for all other objects on the form. When a CommandButton's Cancel property is set to True and the form is the active form, the user can choose the command button by clicking it, pressing ESC, or pressing ENTER when the button has the focus.

A typical use of Cancel is to give the user the option of canceling uncommitted changes and returning the form to its previous state.

You should consider making the Cancel button the default button for forms that support operations that can't be undone (such as delete). To do this, set both Cancel and the Default property to True.


CanPaste Property

Specifies whether the Clipboard contains data that the object supports.

Syntax

object.CanPaste

The CanPaste property syntax has these parts:

Part | Description
object | Required. A valid object.

Return Values

The CanPaste property return values are:

Value | Description
True | The object can receive information pasted from the Clipboard.
False | The object cannot receive information pasted from the Clipboard.

Remarks

CanPaste is read-only.

If the Clipboard data is in a format that the object does not support, the CanPaste property is False. For example, if you try to paste a bitmap into an object that only supports text, CanPaste will be False.


CanRedo Property

Indicates whether the most recent Undo can be reversed.

Syntax

object.CanRedo

The CanRedo property syntax has these parts:

Part | Description
object | Required. A valid object.

Return Values

The CanRedo property syntax return values are:

Value | Description
True | The most recent Undo can be reversed.
False | The most recent Undo is irreversible.

Remarks

CanRedo is read-only.

To Redo an action means to reverse an Undo; it does not necessrily mean to repeat the last user action.


CanUndo Property

Indicates whether the last user action can be undone.

Syntax

object.CanUndo

The CanUndo property syntax has these parts:

Part | Description
object | Required. A valid object.

Return Values

The CanUndo property syntax return values are:

Value | Description
True | The most recent user action can be undone.
False | The most recent user action cannot be undone.

Remarks

CanUndo is read-only.

Many user actions can be undone with the Undo command. The CanUndo property indicates whether the most recent action can be undone.


Caption Property

Descriptive text that appears on an object to identify or describe it.

Syntax

object.Caption [= String]

The Caption property syntax has these parts:

Part | Description
object | Required. A valid object.
String | Optional. A string expression that evaluates to the text displayed as the caption.

Settings

The default setting for a control is a unique name based on the type of control. For example, CommandButton1 is the default caption for the first command button in a form.

Remarks

The text identifies or describes the object with which it is associated. For buttons and labels, the Caption property specifies the text that appears in the control. For Page and Tab objects, it specifies the text that appears on the tab. For the Explorer object, it specifies the text that appears in the explorer’s title bar.

If a control's caption is too long, the caption is truncated. If a form's caption is too long for the title bar, the title is displayed with an ellipsis.

The ForeColor property of the control determines the color of the text in the caption.

Tip If a control has both the Caption and AutoSize properties, setting AutoSize to True automatically adjusts the size of the control to frame the entire caption.


 ClientHeight, ClientLeft, ClientTop, ClientWidth Properties

ClientHeight, ClientLeft, ClientTop, ClientWidth Properties

Define the dimensions and location of the display area of a TabStrip.

Syntax

object.ClientHeight [ =Single]

object.ClientLeft [ =Single]

object.ClientTop [ =Single]

object.ClientWidth [ =Single]

The ClientHeight, ClientLeft, ClientTop, and ClientWidth property syntaxes have these parts:

Part | Description
object | Required. A valid object.
Single | Optional. For ClientHeight and ClientWidth, specifies the height or width, in points, of the display area. For ClientLeft and ClientTop, specifies the distance, in points, from the top or left edge of the TabStrip's container.

Remarks

At run time, ClientLeft, ClientTop, ClientHeight, and ClientWidth automatically store the coordinates and dimensions of the TabStrip's internal area, which is shared by objects in the TabStrip.


 Column Property

Column Property

Specifies one or more items in a ListBox or ComboBox.

Syntax

object.Column( column, row ) [= Variant]

The Column property syntax has these parts:

Part | Description
object | Required. A valid object.
column | Optional. An integer with a range from 0 to one less than the total number of columns.
row | Optional. An integer with a range from 0 to one less than the total number of rows.
Variant | Optional. Specifies a single value, a column of values, or a two-dimensional array to load into a ListBox or ComboBox.

Settings

If you specify both the column and row values, Column reads or writes a specific item.

If you specify only the column value, the Column property reads or writes the specified column in the current row of the object. For example, MyListBox.Column (3) reads or writes the third column in MyListBox.

Column returns a Variant from the cursor. When a built-in cursor provides the value for Variant (such as when using the AddItem method), the value is a string. When an external cursor provides the value for Variant, formatting associated with the data is not included in the Variant.

Remarks

You can use Column to assign the contents of a combo box or list box to another control, such as a text box. For example, you can set the ControlSource property of a text box to the value in the second column of a list box.

If the user makes no selection when you refer to a column in a combo box or list box, the Column setting is Null. You can check for this condition by using the IsNull function.

You can also use Column to copy an entire two-dimensional array of values to a control. This syntax lets you quickly load a list of choices rather than individually loading each element of the list using AddItem.

Note When copying data from a two-dimensional array, Column transposes the contents of the array in the control so that the contents of ListBox1.Column(X, Y) is the same as MyArray(Y, X). You can also use List to copy an array without transposing it.


 ColumnCount Property

ColumnCount Property

Specifies the number of columns to display in a list box or combo box.

Syntax

object.ColumnCount [= Long]

The ColumnCount property syntax has these parts:

Part | Description
object | Required. A valid object.
Long | Optional. Specifies the number of columns to display.

Remarks

If you set the ColumnCount property for a list box to 3 on an employee form, one column can list last names, another can list first names, and the third can list employee ID numbers.

Setting ColumnCount to 0 displays zero columns, and setting it to -1 displays all the available columns. For an unbound data source, there is a 10-column limit (0 to 9).

You can use the ColumnWidths property to set the width of the columns displayed in the control.


ColumnHeads Property

Displays a single row of column headings for list boxes, combo boxes, and objects that accept column headings.

Syntax

object.ColumnHeads [= Boolean]

The ColumnHeads property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Specifies whether the column headings are displayed.

Settings

The settings for Boolean are:

Value | Description
True | Display column headings.
False | Do not display column headings (default).

Headings in combo boxes appear only when the list drops down.

Remarks

When the system uses the first row of data items as column headings, they can't be selected.


 ColumnWidths Property

ColumnWidths Property

Specifies the width of each column in a multicolumn ComboBox or ListBox.

Syntax

object.ColumnWidths [= String]

The ColumnWidths property syntax has these parts:

Part | Description
object | Required. A valid object.
String | Optional. Sets the column width in points. A setting of –1 or blank results in a calculated width. A width of 0 hides a column. To specify a different unit of measurement, include the unit of measure. A value greater than 0 explicitly specifies the width of the column.

Settings

To separate column entries, use semicolons (;) as list separators. Or use the list separator specified in the Regional Settings section of the Windows Control Panel.

Any or all of the ColumnWidths property settings can be blank. You create a blank setting by typing a list separator without a preceding value.

If you specify a –1 in the property page, the displayed value in the property page is a blank.

To calculate column widths when ColumnWidths is blank or –1, the width of the control is divided equally among all columns of the list. If the sum of the specified column widths exceeds the width of the control, the list is left-aligned within the control and one or more of the rightmost columns are not displayed. Users can scroll the list using the horizontal scroll bar to display the rightmost columns.

The minimum calculated column width is 72 points (1 inch). To produce columns narrower than this, you must specify the width explicitly.

Unless specified otherwise, column widths are measured in points. To specify another unit of measure, include the units as part of the values. The following examples specify column widths in several units of measure and describe how the various settings would fit in a three-column list box that is 4 inches wide.

Setting | Effect
90;72;90 | The first column is 90 points (1.25 inch); the second column is 72 points (1 inch); the third column is 90 points.
6 cm;0;6 cm | The first column is 6 centimeters; the second column is hidden; the third column is 6 centimeters. Because part of the third column is visible, a horizontal scroll bar appears.
1.5 in;0;2.5 in | The first column is 1.5 inches, the second column is hidden, and the third column is 2.5 inches.
2 in;;2 in | The first column is 2 inches, the second column is 1 inch (default), and the third column is 2 inches. Because only half of the third column is visible, a horizontal scroll bar appears.
(Blank) | All three columns are the same width (1.33 inches).

Remarks

In a ComboBox, the system displays the column designated by the TextColumn property in the text box portion of the control. Setting TextColumn to –1 displays the first column that has a ColumnWidths value greater than 0.


 ControlTipText Property

ControlTipText Property

Specifies text that appears when the user briefly holds the mouse pointer over a control without clicking.

Syntax

object.ControlTipText [= String]

The ControlTipText property syntax has these parts:

Part | Description
object | Required. A valid object.
String | Optional. The text that appears when the user holds the mouse pointer over a control.

Remarks

The ControlTipText property lets you give users tips about a control in a running form. The property can be set during design time but only appears by the control during run time.

The default value of ControlTipText is an empty string. When the value of ControlTipText is set to an empty string, no tip is available for that control.


 Count Property

Count Property

Returns the number of objects in a collection.

Syntax

object.Count

The Count property syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

The Count property is read only.

Note that the index value for the first page or tab of a collection is zero, the value for the second page or tab is one, and so on. For example, if a MultiPage contains two pages, the indexes of the pages are 0 and 1, and the value of Count is 2.


CurLine Property

Specifies the current line of a control.

Syntax

object.CurLine [= Long]

The CurLine property syntax has these parts:

Part | Description
object | Required. A valid object.
Long | Optional. Specifies the current line of a control.

Remarks

The current line of a control is the line that contains the insertion point. The number of the first line is 0.

The CurLine property is valid when the control has focus.


 CurTargetX Property

CurTargetX Property

Retrieves the preferred horizontal position of the insertion point in a multiline TextBox or ComboBox.

Syntax

object.CurTargetX

The CurTargetX property syntax has these parts:

Part | Description
object | Required. A valid object.

Return Values

The CurTargetX property retrieves the preferred position, measured in himetric units. A himetric is 0.0001 meter.

Remarks

The target position is relative to the left edge of the control. If the length of a line is less than the value of the CurTargetX property, you can place the insertion point at the end of the line. The value of CurTargetX changes when the user sets the insertion point or when the CurX property is set. CurTargetX is read-only.

The return value is valid when the object has focus

You can use CurTargetX and CurX to move the insertion point as the user scrolls through the contents of a multiline TextBox or ComboBox. When the user moves the insertion point to another line of text by scrolling the content of the object, CurTargetX specifies the preferred position for the insertion point. CurX is set to this value if the line of text is longer than the value of CurTargetX. Otherwise, CurX is set to the end of the line of text.


 CurX Property

CurX Property

Specifies the current horizontal position of the insertion point in a multiline TextBox or ComboBox.

Syntax

object.CurX [= Long]

The CurX property syntax has these parts:

Part | Description
object | Required. A valid object.
Long | Optional. Indicates the current position, measured in himetrics. A himetric is 0.0001 meter.

Remarks

The CurX property applies to a multiline TextBox or ComboBox. The return value is valid when the object has the focus

You can use CurTargetX and CurX to position the insertion point as the user scrolls through the contents of a multiline TextBox or ComboBox. When the user moves the insertion point to another line of text by scrolling the content of the object, CurTargetX specifies the preferred position for the insertion point. CurX is set to this value if the line of text is longer than the value of CurTargetX. Otherwise, CurX is set to the end of the line of text.


 Cycle Property

Cycle Property

Specifies the action to take when the user leaves the last control on a Frame or Page.

Syntax

object.Cycle [=Cycle]

The Cycle property syntax has these parts:

Part | Description
object | Required. A valid object.
Cycle | Optional. Specifies whether cycling includes controls nested in a Frame or MultiPage.

Settings

The settings for Cycle are:

Value | Description
0 | Cycles through the controls on the form and the controls of the Frame and MultiPage controls that are currently displayed on the form.
2 | Cycles through the controls on the form, Frame, or MultiPage. The focus stays within the form, Frame, or MultiPage until the focus is explicitly set to a control outside the form, Frame, or MultiPage.

If you specify a non-integer value for Cycle, the value is rounded up to the nearest integer.

Remarks

The tab order identifies the order in which controls receive the focus as the user tabs through a form or subform. The Cycle property determines the action to take when a user tabs from the last control in the tab order.

The 0 setting transfers the focus to the first control of the next Frame or MultiPage on the form when the user tabs from the last control in the tab order.

The 2 setting transfers the focus to the first control of the same form, Frame, or MultiPage when the user tabs from the last control in the tab order.


 Default Property

Default Property

Designates the default CommandButton on a form.

Syntax

object.Default [= Boolean]

The Default property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the command button is the default.

Settings

The settings for Boolean are:

Value | Description
True | The CommandButton is the default button.
False | The CommandButton is not the default button (default).

Remarks

A CommandButton or an object that acts like a command button can be designated as the default command button. Only one object on a form can be the default command button. Setting the Default property to True for one object automatically sets it to False for all other objects on the form.

To choose the default command button on an active form, the user can click the button, or press ENTER when no other CommandButton has the focus.

Default is provided for OLE container controls that specifically act like CommandButton controls.

Tip You should consider making the Cancel button the default button for forms that support operations that can't be undone (such as delete). To do this, set both Default and the Cancel property to True.


Delay Property

Specifies the delay on a SpinButton or ScrollBar.

Syntax

object.Delay [= Long]

The Delay property syntax has these parts:

Part | Description
object | Required. A valid object.
Long | Optional. The delay, in milliseconds, between events.

Remarks

The Delay property affects the amount of time between consecutive SpinUp, SpinDown, and Change events generated when the user clicks and holds down a button on a SpinButton or ScrollBar. The first event occurs immediately. The delay to the second occurrence of the event is five times the value of the specified Delay. This initial lag makes it easy to generate a single event rather than a stream of events.

After the initial lag, the interval between events is the value specified for Delay.

The default value of Delay is 50 milliseconds. This means the object initiates the first event after 250 milliseconds (5 times the specified value) and initiates each subsequent event after 50 milliseconds.


DragBehavior Property

Specifies whether the system enables the drag-and-drop feature for a TextBox or ComboBox.

Syntax

object.DragBehavior [=DragBehavior]

The DragBehavior property syntax has these parts:

Part | Description
object | Required. A valid object.
DragBehavior | Optional. Specifies whether the drag-and-drop feature is enabled.

Settings

The settings for DragBehavior are:

Value | Description
0 | Does not allow a drag-and-drop action (default).
1 | Allows a drag-and-drop action.

Remarks

If the DragBehavior property is enabled, dragging in a text box or combo box starts a drag-and-drop operation on the selected text. If DragBehavior is disabled, dragging in a text box or combo box selects text.

The drop-down portion of a ComboBox does not support drag-and-drop processes, nor does it support selection of list items within the text.

DragBehavior has no effect on a ComboBox whose Style property is set to 2.

Note You can combine the effects of the EnterFieldBehavior property and DragBehavior to create a large number of text box styles.


DropButtonStyle Property

Specifies the symbol displayed on the drop button in a ComboBox.

Syntax

object.DropButtonStyle [=DropButtonStyle]

The DropButtonStyle property syntax has these parts:

Part | Description
object | Required. A valid object.
DropButtonStyle | Optional. The appearance of the drop button.

Settings

The settings for DropButtonStyle are:

Value | Description
0 | Displays a plain button, with no symbol.
1 | Displays a down arrow (default).
2 | Displays an ellipsis (...).
3 | Displays a horizontal line like an underscore character.

Remarks

The recommended setting for showing items in a list is 1.


 Enabled Property

Enabled Property

Specifies whether a control can receive the focus and respond to user-generated events.

Syntax

object.Enabled [= Boolean]

The Enabled property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the object can respond to user-generated events.

Settings

The settings for Boolean are:

Value | Description
True | The control can receive the focus and respond to user-generated events, and is accessible through code (default).
False | The user cannot interact with the control by using the mouse, keystrokes, accelerators, or hotkeys. The control is generally still accessible through code.

Remarks

Use the Enabled property to enable and disable controls. A disabled control appears dimmed, while an enabled control does not. Also, if a control displays a bitmap, the bitmap is dimmed whenever the control is dimmed. If Enabled is False for an Image, the control does not initiate events but does not appear dimmed.

The Enabled and Locked properties work together to achieve the following effects:

  • If Enabled and Locked are both True, the control can receive focus and appears normally (not dimmed) in the form. The user can copy, but not edit, data in the control.

  • If Enabled is True and Locked is False, the control can receive focus and appears normally in the form. The user can copy and edit data in the control.

  • If Enabled is False and Locked is True, the control cannot receive focus and is dimmed in the form. The user can neither copy nor edit data in the control.

  • If Enabled and Locked are both False, the control cannot receive focus and is dimmed in the form. The user can neither copy nor edit data in the control.

You can combine the settings of the Enabled and the TabStop properties to prevent the user from selecting a command button with TAB, while still allowing the user to click the button. Setting TabStop to False means that the command button won't appear in the tab order. However, if Enabled is True, then the user can still click the command button, as long as TakeFocusOnClick is set to True.

When the user tabs into an enabled MultiPage or TabStrip, the first page or tab in the control receives the focus. If the first page or tab of a MultiPage or TabStrip is disabled, the first enabled page or tab of that control receives the focus. If all pages or tabs of a MultiPage or TabStrip are disabled, the control is disabled and cannot receive the focus.

If a Frame is disabled, all controls that it contains are disabled.

Clicking a disabled ListBox does not initiate the Click event.


 EnterFieldBehavior Property

EnterFieldBehavior Property

Specifies the selection behavior when entering a TextBox or ComboBox.

Syntax

object.EnterFieldBehavior [=EnterFieldBehavior]

The EnterFieldBehavior property syntax has these parts:

Part | Description
object | Required. A valid object.
EnterFieldBehavior | Optional. The desired selection behavior.

Settings

The settings for EnterFieldBehavior are:

Value | Description
0 | Selects the entire contents of the edit region when entering the control (default).
1 | Leaves the selection unchanged. Visually, this uses the selection that was in effect the last time the control was active.

Remarks

The EnterFieldBehavior property controls the way text is selected when the user tabs to the control, not when the control receives focus as a result of the SetFocus method. Following SetFocus, the contents of the control are not selected and the insertion point appears after the last character in the control's edit region.

Note You can combine the effects of the EnterFieldBehavior property and DragBehavior to create a large number of text box styles.


 EnterKeyBehavior Property

EnterKeyBehavior Property

Defines the effect of pressing ENTER in a TextBox.

Syntax

object.EnterKeyBehavior [= Boolean]

The EnterKeyBehavior property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Specifies the effect of pressing ENTER.

Settings

The settings for Boolean are:

Value | Description
True | Pressing ENTER creates a new line.
False | Pressing ENTER moves the focus to the next object in the tab order (default).

Remarks

The EnterKeyBehavior and MultiLine properties are closely related. The values described above only apply if MultiLine is True. If MultiLine is False, pressing ENTER always moves the focus to the next control in the tab order regardless of the value of EnterKeyBehavior.

The effect of pressing CTRL+ENTER also depends on the value of MultiLine. If MultiLine is True, pressing CTRL+ENTER creates a new line regardless of the value of EnterKeyBehavior. If MultiLine is False, pressing CTRL+ENTER has no effect.


 ForeColor Property

ForeColor Property

Specifies the foreground color of an object.

Syntax

object.ForeColor [= Long]

The ForeColor property syntax has these parts:

Part | Description
object | Required. A valid object.
Long | Optional. A value or constant that determines the foreground color of an object.

Settings

You can use any integer that represents a valid color. You can also specify a color by using the RGB function with red, green, and blue color components. The value of each color component is an integer that ranges from zero to 255. For example, you can specify teal blue as the integer value 4966415 or as red, green, and blue color components 15, 200, 75, as shown in the following example.

RGB(15,200,75)

Remarks

Use the ForeColor property for controls on forms to make them easy to read or to convey a special meaning. For example, if a text box reports the number of units in stock, you can change the color of the text when the value falls below the reorder level.

For a ScrollBar or SpinButton, ForeColor sets the color of the arrows. For a Frame, ForeColor changes the color of the caption. For a Font object, ForeColor determines the color of the text.


 GroupName Property

GroupName Property

Creates a group of mutually exclusive OptionButton controls.

Syntax

object.GroupName [= String]

The GroupName property syntax has these parts:

Part | Description
object | Required. A valid OptionButton.
String | Optional. The name of the group that includes the OptionButton. Use the same setting for all buttons in the group. The default setting is an empty string.

Remarks

To create a group of mutually exclusive OptionButton controls, you can put the buttons in a Frame on your form, or you can use the GroupName property. GroupName is more efficient for the following reasons:

  • You do not have to include a Frame for each group. By not using a Frame, you reduce the number of controls on the form, and in turn, improve performance and reduce the size of the form.

  • You have more design flexibility. If you use a Frame to create the group, all the buttons must be inside the Frame. If you want more than one group, you must have one Frame for each group. However, if you use GroupName to create the group, the group can include option buttons anywhere on the form. If you want more than one group, specify a unique name for each group; you can still place the individual controls anywhere on the form.

  • You can create buttons with transparent backgrounds, which can improve the visual appearance of your form. The Frame is not a transparent control.

Regardless of which method you use to create the group of buttons, clicking one button in a group sets all other buttons in the same group to False. All option buttons with the same GroupName within a single container are mutually exclusive. You can use the same group name in two containers, but doing so creates two groups (one in each container) rather than one group that includes both containers.

For example, assume your form includes some option buttons and a MultiPage that also includes option buttons. The option buttons on the MultiPage are one group and the buttons on the form are another group. The two groups do not affect each other. Changing the setting of a button on the MultiPage does not affect the buttons on the form.


 Height, Width Properties

Height, Width Properties

The height or width, in points, of an object.

Syntax

object.Height [= Single]

object.Width [= Single]

The Height and Width property syntaxes have these parts:

Part | Description
object | Required. A valid object.
Single | Optional. A numeric expression specifying the dimensions of an object.

Remarks

The Height and Width properties are automatically updated when you move or size a control. If you specify a setting for the Left or Top property that is less than zero, that value will be used to calculate the height or width of the control, but a portion of the control will not be visible on the form.

If you move a control from one part of a form to another, the setting of Height or Width only changes if you size the control as you move it. The settings of the control's Left and Top properties will change to reflect the control's new position relative to the edges of the form that contains it.

The value assigned to Height or Width must be greater than or equal to zero. For most systems, the recommended range of values is from 0 to +32,767. Higher values may also work depending on your system configuration.

For most systems, the recommended range of values for Left and Top is from -32,767 to +32,767. Other values may also work depending on your system configuration. For a ComboBox, values of Left and Top apply to the text portion of the control, not to the list portion. When you move or size a control, its new Left setting is automatically entered in the property sheet. When you print a form, the control's horizontal or vertical location is determined by its Left or Top setting.


 HideSelection Property

HideSelection Property

Specifies whether selected text remains highlighted when a control does not have the focus.

Syntax

object.HideSelection [= Boolean]

The HideSelection property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the selected text remains highlighted even when the control does not have the focus.

Settings

The settings for Boolean are:

Value | Description
True | Selected text is not highlighted unless the control has the focus (default).
False | Selected text always appears highlighted.

Remarks

You can use the HideSelection property to maintain highlighted text when another form or a dialog box receives the focus, such as in a spell-checking procedure.


 IMEMode Property

IMEMode Property

Specifies the default run-time mode of the Input Method Editor (IME) for a control. This property applies only to applications written for Asian languages and is ignored in other applications.

Syntax

object.IMEMode [= fmIMEMode]

The IMEMode property syntax has these parts:

Part | Description
object | Required. A valid object.
fmIMEMode | Optional. The mode of the Input Method Editor (IME).

Settings

The settings for fmIMEMode are:

Value | Description
0 | Does not control IME (default).
1 | IME on.
2 | IME off. English mode.
3 | IME off. User can’t turn on IME by keyboard.
4 | IME on with Full-width Hiragana mode.
5 | IME on with Full-width Katakana mode.
6 | IME on with Half-width Katakana mode.
7 | IME on with Full-width Alphanumeric mode.
8 | IME on with Half-width Alphanumeric mode.
9 | IME on with Full-width Hangul mode.
10 | IME on with Half-width Hangul mode.

A setting of 0 indicates that the mode of the IME does not change when the control receives focus at run time. For any other value, the mode of the IME is set to the value specified by the IMEMode property when the control receives focus at run time.


Index Property

The position of a Tab object within a Tabs collection or a Page object in a Pages collection.

Syntax

object.Index [= Integer]

The Index property syntax has these parts:

Part | Description
object | Required. A valid object.
Integer | Optional. The index of the currently selected Tab object.

Remarks

The Index property specifies the order in which tabs appear. Changing the value of Index visually changes the order of Pages in a MultiPage or Tabs on a TabStrip. The index value for the first page or tab is zero, the index value of the second page or tab is one, and so on.

In a MultiPage, Index refers to a Page as well as the page's Tab. In a TabStrip, Index refers to the tab only.


 InsideHeight, InsideWidth Properties

InsideHeight, InsideWidth Properties

InsideHeight returns the height, in points, of the client region inside a Frame. InsideWidth returns the width, in points, of the client region inside a Frame.

Syntax

object.InsideHeight

object.InsideWidth

The InsideHeight and InsideWidth property syntaxes have these parts:

Part | Description
object | Required. A valid object.

Remarks

The InsideHeight and InsideWidth properties are read-only.


IntegralHeight Property

Indicates whether a ListBox or TextBox displays full lines of text in a list or partial lines.

Syntax

object.IntegralHeight [= Boolean]

The IntegralHeight property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the list displays partial lines of text.

Settings

The settings for Boolean are:

Value | Description
True | The list resizes itself to display only complete items (default).
False | The list does not resize itself even if the item is too tall to display completely.

Remarks

The IntegralHeight property relates to the height of the list, just as the AutoSize property relates to the width of the list.

If IntegralHeight is True, the list box automatically resizes when necessary to show full rows. If False, the list remains a fixed size; if items are taller than the available space in the list, the entire item is not shown.


KeepScrollBarsVisible Property

Specifies whether scroll bars remain visible when not required.

Syntax

object.KeepScrollBarsVisible [=ScrollBars]

The KeepScrollBarsVisible property syntax has these parts:

Part | Description
object | Required. A valid object.
ScrollBars | Optional. Where scroll bars are displayed.

Settings

The settings for ScrollBars are:

Value | Description
0 | Displays no scroll bars.
1 | Displays a horizontal scroll bar.
2 | Displays a vertical scroll bar.
3 | Displays both a horizontal and a vertical scroll bar (default).

Remarks

If the visible region is large enough to display all the controls on an object such as a Page object, scroll bars are not required. The KeepScrollBarsVisible property determines whether the scroll bars remain visible when they are not required.

If the scroll bars are visible when they are not required, they appear normal in size, and the scroll box fills the entire width or height of the scroll bar.

If the KeepScrollBarsVisible property is True, any scroll bar on a form or page is always visible, regardless of whether the object's contents fit within the object's borders.


LargeChange Property

Specifies the amount of movement that occurs when the user clicks between the scroll box and scroll arrow.

Syntax

object.LargeChange [= Long]

The LargeChange property syntax has these parts:

Part | Description
object | Required. A valid object.
Long | Optional. An integer that specifies the amount of change to the Value property.

Remarks

The LargeChange property applies only to the ScrollBar. It does not apply to the scrollbars in other controls such as a TextBox or a drop-down ComboBox.

The value of LargeChange is the amount by which the ScrollBar's Value property changes when the user clicks the area between the scroll box and scroll arrow. The direction of the movement is always toward the place where the user clicks. For example, in a horizontal ScrollBar, clicking to the left of the scroll box moves the scroll box to the left. In a vertical ScrollBar, clicking above the scroll box moves the scroll box up.

LargeChange does not have units. Any integer is a valid setting for LargeChange. The recommended range of values is from –32,767 to +32,767, and the value must be between the values of the Max and Min properties of the ScrollBar.


 Left, Top Properties

Left, Top Properties

The distance between a control and the left or top edge of the form that contains it.

Syntax

object.Left [= Single]

object.Top [= Single]

The Left and Top property syntaxes have these parts:

Part | Description
object | Required. A valid object.
Single | Optional. A numeric expression specifying the coordinates of an object.

Settings

Setting the Left or Top property to 0 places the control's edge at the left or top edge of its container.

Remarks

For most systems, the recommended range of values for Left and Top is from -32,767 to +32,767. Other values may also work depending on your system configuration. For a ComboBox, values of Left and Top apply to the text portion of the control, not to the list portion. When you move or size a control, its new Left setting is automatically entered in the property sheet. When you print a form, the control's horizontal or vertical location is determined by its Left or Top setting.

The Height and Width properties are automatically updated when you move or size a control. If you specify a setting for the Left or Top property that is less than zero, that value will be used to calculate the height or width of the control, but a portion of the control will not be visible on the form.

If you move a control from one part of a form to another, the setting of Height or Width only changes if you size the control as you move it. The settings of the control's Left and Top properties will change to reflect the control's new position relative to the edges of the form that contains it.

The value assigned to Height or Width must be greater than or equal to zero. For most systems, the recommended range of values is from 0 to +32,767. Higher values may also work depending on your system configuration.


LineCount Property

Returns the number of text lines in a TextBox or ComboBox.

Syntax

object.LineCount

The LineCount property syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

The LineCount property is read-only.

Note A ComboBox will only have one line.


 List Property

List Property

Returns or sets the list entries of a ListBox or ComboBox.

Syntax

object.List( row, column ) [= Variant]

The List property syntax has these parts:

Part | Description
object | Required. A valid object.
row | Required. An integer with a range from 0 to one less than the number of entries in the list.
column | Required. An integer with a range from 0 to one less than the number of columns.
Variant | Optional. The contents of the specified entry in the ListBox or ComboBox.

Settings

Row and column numbering begins with zero. That is, the row number of the first row in the list is zero; the column number of the first column is zero. The number of the second row or column is 1, and so on.

Remarks

The List property works with the ListCount and ListIndex properties. Use List to access list items. A list is a variant array; each item in the list has a row number and a column number.

Initially, ComboBox and ListBox contain empty lists.

Note To specify items you want to display in a ComboBox or ListBox, use the AddItem method. To remove items, use the RemoveItem method.

Use List to copy an entire two-dimensional array of values to a control. Use AddItem to load a one-dimensional array or to load an individual element.


ListCount Property

Returns the number of list entries in a control.

Syntax

object.ListCount

The ListCount property syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

The ListCount property is read-only. ListCount is the number of rows over which you can scroll. ListCount is always one greater than the largest value for the ListIndex property, because index numbers begin with 0 and the count of items begins with 1. If no item is selected, ListCount is 0 and ListIndex is –1.


 ListIndex Property

ListIndex Property

Identifies the currently selected item in a ListBox or ComboBox.

Syntax

object.ListIndex [= Variant]

The ListIndex property syntax has these parts:

Part | Description
object | Required. A valid object.
Variant | Optional. The currently selected item in the control.

Remarks

The ListIndex property contains an index of the selected row in a list. Values of ListIndex range from –1 to one less than the total number of rows in a list (that is, ListCount – 1). When no rows are selected, ListIndex returns –1. When the user selects a row in a ListBox or ComboBox, the system sets the ListIndex value. The ListIndex value of the first row in a list is 0, the value of the second row is 1, and so on.

Note If you use the MultiSelect property to create a ListBox that allows multiple selections, the Selected property of the ListBox (rather than the ListIndex property) identifies the selected rows. The Selected property is an array with the same number of values as the number of rows in the ListBox. For each row in the list box, Selected is True if the row is selected and False if it is not. In a ListBox that allows multiple selections, ListIndex returns the index of the row that has focus, regardless of whether that row is currently selected.

The ListIndex value is also available by setting the BoundColumn property to 0 for a combo box or list box. If BoundColumn is 0, the underlying data source to which the combo box or list box is bound contains the same list index value as ListIndex.


ListRows Property

Specifies the maximum number of rows to display in the list.

Syntax

object.ListRows [= Long]

The ListRows property syntax has these parts:

Part | Description
object | Required. A valid object.
Long | Optional. An integer indicating the maximum number of rows. The default value is 8.

Remarks

If the number of items in the list exceeds the value of the ListRows property, a scroll bar appears at the right edge of the list-box portion of the combo box.


ListStyle Property

Specifies the visual appearance of the list in a ListBox or ComboBox.

Syntax

object.ListStyle [=ListStyle]

The ListStyle property syntax has these parts:

Part | Description
object | Required. A valid object.
ListStyle | Optional. The visual style of the list.

Settings

The settings for ListStyle are:

Value | Description
0 | Looks like a regular list box, with the background of items highlighted.
1 | Shows option buttons, or check boxes for a multi-select list (default). When the user selects an item from the group, the option button associated with that item is selected and the option buttons for the other items in the group are deselected.

Remarks

The ListStyle property lets you change the visual presentation of a ListBox or ComboBox. By specifying a setting other than 0, you can present the contents of either control as a group of individual items, with each item including a visual cue to indicate whether it is selected.

If the control supports a single selection (the MultiSelect property is set to 0), the user can press one button in the group. If the control supports multi-select, the user can press two or more buttons in the group.


ListWidth Property

Specifies the width of the list in a ComboBox.

Syntax

object.ListWidth [= Variant]

The ListWidth property syntax has these parts:

Part | Description
object | Required. A valid object.
Variant | Optional. The width of the list. A value of zero makes the list as wide as the ComboBox. The default value is to make the list as wide as the text portion of the control.

Remarks

If you want to display a multicolumn list, enter a value that will make the list box wide enough to fit all the columns.

Tip When designing combo boxes, be sure to leave enough space to display your data and for a vertical scroll bar.


 Locked Property

Locked Property

Specifies whether a control can be edited.

Syntax

object.Locked [= Boolean]

The Locked property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the control can be edited.

Settings

The settings for Boolean are:

Value | Description
True | You can't edit the value.
False | You can edit the value (default).

Remarks

When a control is locked and enabled, it can still initiate events and can still receive the focus.

The Enabled and Locked properties work together to achieve the following effects:

  • If Enabled and Locked are both True, the control can receive focus and appears normally (not dimmed) in the form. The user can copy, but not edit, data in the control.

  • If Enabled is True and Locked is False, the control can receive focus and appears normally in the form. The user can copy and edit data in the control.

  • If Enabled is False and Locked is True, the control cannot receive focus and is dimmed in the form. The user can neither copy nor edit data in the control.

  • If Enabled and Locked are both False, the control cannot receive focus and is dimmed in the form. The user can neither copy nor edit data in the control.


 MatchEntry Property

MatchEntry Property

Returns or sets a value indicating how a ListBox or ComboBox searches its list as the user types.

Syntax

object.MatchEntry [=MatchEntry]

The MatchEntry property syntax has these parts:

Part | Description
object | Required. A valid object.
MatchEntry | Optional. The rule used to match entries in the list.

Settings

The settings for MatchEntry are:

Value | Description
0 | Basic matching. The control searches for the next entry that starts with the character entered. Repeatedly typing the same letter cycles through all entries beginning with that letter.
1 | Extended matching. As each character is typed, the control searches for an entry matching all characters entered (default).
2 | No matching.

Remarks

The MatchEntry property searches entries from the TextColumn property of a ListBox or ComboBox.

The control searches the column identified by TextColumn for an entry that matches the user's typed entry. Upon finding a match, the row containing the match is selected, the contents of the column are displayed, and the contents of its BoundColumn property become the value of the control. If the match is unambiguous, finding the match initiates the Click event.

The control initiates the Click event as soon as the user types a sequence of characters that match exactly one entry in the list. As the user types, the entry is compared with the current row in the list and with the next row in the list. When the entry matches only the current row, the match is unambiguous.

In Microsoft Forms, this is true regardless of whether the list is sorted. This means the control finds the first occurrence that matches the entry, based on the order of items in the list. For example, entering either "abc" or "bc" will initiate the Click event for the following list:

abcde
bcdef
abcxyz
bchij

Note that in either case, the matched entry is not unique; however, it is sufficiently different from the adjacent entry that the control interprets the match as unambiguous and initiates the Click event.


MatchFound Property

Indicates whether the text that a user has typed into a ComboBox matches any of the entries in the list.

Syntax

object.MatchFound

The MatchFound property syntax has these parts:

Part | Description
object | Required. A valid object.

Return Values

The MatchFound property return values are:

Value | Description
True | The contents of the Value property matches one of the records in the list.
False | The contents of Value does not match any of the records in the list (default).

Remarks

The MatchFound property is read-only. It is not applicable when the MatchEntry property is set to 2.


 MatchRequired Property

MatchRequired Property

Specifies whether a value entered in the text portion of a ComboBox must match an entry in the existing list portion of the control. The user can enter non-matching values, but may not leave the control until a matching value is entered.

Syntax

object.MatchRequired [= Boolean]

The MatchRequired property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the text entered must match an existing item in the list.

Settings

The settings for Boolean are:

Value | Description
True | The text entered must match an existing list entry.
False | The text entered can be different from all existing list entries (default).

Remarks

If the MatchRequired property is True, the user cannot exit the ComboBox until the text entered matches an entry in the existing list. MatchRequired maintains the integrity of the list by requiring the user to select an existing entry.

Note Not all containers enforce this property.


Max, Min Properties

Specify the maximum and minimum acceptable values for the Value property of a ScrollBar or SpinButton.

Syntax

object.Max [= Long]

object.Min [= Long]

The Max and Min property syntaxes have these parts:

Part | Description
object | Required. A valid object.
Long | Optional. A numeric expression specifying the maximum or minimum Value property setting.

Remarks

Clicking a SpinButton or moving the scroll box in a ScrollBar changes the Value property of the control.

The value for the Max property corresponds to the lowest position of a vertical ScrollBar or the rightmost position of a horizontal ScrollBar. The value for the Min property corresponds to the highest position of a vertical ScrollBar or the leftmost position of a horizontal ScrollBar.

Any integer is an acceptable setting for this property. The recommended range of values is from –32,767 to +32,767. The default value is 1.

Note Min and Max refer to locations, not to relative values, on the ScrollBar. That is, the value of Max could be less than the value of Min. If this is the case, moving toward the Max (bottom) position means decreasing Value; moving toward the Min (top) position means increasing Value.


MaxLength Property

Specifies the maximum number of characters a user can enter in a TextBox or ComboBox.

Syntax

object.MaxLength [= Long]

The MaxLength property syntax has these parts:

Part | Description
object | Required. A valid object.
Long | Optional. An integer indicating the allowable number of characters.

Remarks

Setting the MaxLength property to 0 indicates there is no limit other than that created by memory constraints.


MouseIcon Property

Assigns a custom icon to an object.

Syntax

object.MouseIcon = LoadPicture( pathname )

The MouseIcon property syntax has these parts:

Part | Description
object | Required. A valid object.
pathname | Required. A string expression specifying the path and filename of the file containing the custom icon.

Remarks

The MouseIcon property is valid when the MousePointer property is set to 99. The mouse icon of an object is the image that appears when the user moves the mouse across that object.

To assign an image for the mouse pointer, you can either assign a picture to the MouseIcon property or load a picture from a file using the LoadPicture function.


MousePointer Property

Specifies the type of pointer displayed when the user positions the mouse over a particular object.

Syntax

object.MousePointer [=MousePointer]

The MousePointer property syntax has these parts:

Part | Description
object | Required. A valid object.
MousePointer | Optional. The shape you want for the mouse pointer.

Settings

The settings for MousePointer are:

Value | Description
0 | Standard pointer. The image is determined by the object (default).
1 | Arrow.
2 | Cross-hair pointer.
3 | I-beam.
6 | Double arrow pointing northeast and southwest.
7 | Double arrow pointing north and south.
8 | Double arrow pointing northwest and southeast.
9 | Double arrow pointing west and east.
10 | Up arrow.
11 | Hourglass.
12 | "Not" symbol (circle with a diagonal line) on top of the object being dragged. Indicates an invalid drop target.
13 | Arrow with an hourglass.
14 | Arrow with a question mark.
15 | Size all cursor (arrows pointing north, south, east, and west).
99 | Uses the icon specified by the MouseIcon property.

Remarks

Use the MousePointer property when you want to indicate changes in functionality as the mouse pointer passes over controls on a form. For example, the hourglass setting (11) is useful to indicate that the user must wait for a process or operation to finish.

Some icons vary depending on system settings, such as the icons associated with desktop themes.


 MultiLine Property

MultiLine Property

Specifies whether a control can accept and display multiple lines of text.

Syntax

object.MultiLine [= Boolean]

The MultiLine property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the control supports more than one line of text.

Settings

The settings for Boolean are:

Value | Description
True | The text is displayed across multiple lines (default).
False | The text is not displayed across multiple lines.

Remarks

A multiline TextBox allows absolute line breaks and adjusts its quantity of lines to accommodate the amount of text it holds. If needed, a multiline control can have vertical scroll bars.

A single-line TextBox doesn't allow absolute line breaks and doesn't use vertical scroll bars.

For controls that support the MultiLine property as well as the WordWrap property, WordWrap is ignored when MultiLine is False.

Single-line controls ignore the value of the WordWrap property.

Note If you change MultiLine to False in a multiline TextBox, all the characters in the TextBox will be combined into one line, including non-printing characters (such as carriage returns and new-lines).

The EnterKeyBehavior and MultiLine properties are closely related. The EnterKeyBehavior values of True and False only apply if MultiLine is True. If MultiLine is False, pressing ENTER always moves the focus to the next control in the tab order regardless of the value of EnterKeyBehavior.

The effect of pressing CTRL+ENTER also depends on the value of MultiLine. If MultiLine is True, pressing CTRL+ENTER creates a new line regardless of the value of EnterKeyBehavior. If MultiLine is False, pressing CTRL+ENTER has no effect.

The TabKeyBehavior and MultiLine properties are closely related. The values described above only apply if MultiLine is True. If MultiLine is False, pressing TAB always moves the focus to the next control in the tab order regardless of the value of TabKeyBehavior.

The effect of pressing CTRL+TAB also depends on the value of MultiLine. If MultiLine is True, pressing CTRL+TAB creates a new line regardless of the value of TabKeyBehavior. If MultiLine is False, pressing CTRL+TAB has no effect.


MultiRow Property

Specifies whether the control has more than one row of tabs.

Syntax

object.MultiRow [= Boolean]

The MultiRow property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the control has more than one row of tabs.

Settings

The settings for Boolean are:

Value | Description
True | Allows more than one row of tabs.
False | Restricts tabs to a single row (default).

Remarks

The width and number of tabs determines the number of rows. Changing the control's size also changes the number of rows. This allows the developer to resize the control and ensure that tabs wrap to fit the control. If the MultiRow property is False, then truncation occurs if the width of the tabs exceeds the width of the control.

If MultiRow is False and tabs are truncated, there will be a small scroll bar on the TabStrip to allow scrolling to the other tabs or pages.


 MultiSelect Property

MultiSelect Property

Indicates whether the object permits multiple selections.

Syntax

object.MultiSelect [=MultiSelect]

The MultiSelect property syntax has these parts:

Part | Description
object | Required. A valid object.
MultiSelect | Optional. The selection mode that the control uses.

Settings

The settings for MultiSelect are:

Value | Description
0 | Only one item can be selected (default).
1 | Pressing the SPACEBAR or clicking selects or deselects an item in the list.
2 | Pressing SHIFT and clicking the mouse, or pressing SHIFT and one of the arrow keys, extends the selection from the previously selected item to the current item. Pressing CTRL and clicking the mouse selects or deselects an item.

Remarks

When the MultiSelect property is set to Extended or Simple, you must use the list box's Selected property to determine the selected items. Also, the Value property of the control is always Null.

The ListIndex property returns the index of the row with the keyboard focus.<P>


 Name Property

Name Property

Specifies the name of a control or an object, or the name of a font to associate with a Font object.

Syntax

For Font
Font.Name [= String]

For all other controls and objects
object.Name [= String]

The Name property syntax has these parts:

Part | Description
object | Required. A valid object.
String | Optional. The name you want to assign to the font or control.

Settings

Guidelines for assigning a string to Name, such as the maximum length of the name, vary from one application to another.

Remarks

For objects, the default value of Name consists of the object's class name followed by an integer. For example, the default name for the first TextBox you place on a form is TextBox1. The default name for the second TextBox is TextBox2.

You can set the Name property for a control from the control's property sheet or, for controls added at run time, by using program statements. If you add a control at design time, you cannot modify its Name property at run time.

Each control added to a form at design time must have a unique name.

For Font objects, Name identifies a particular typeface to use in the text portion of a control, object, or form. The font's appearance on screen and in print may differ, depending on your computer and printer. If you select a font that your system can't display or that isn't installed, Windows substitutes a similar font.


Object Property

Overrides a standard property or method when a new control has a property or method of the same name.

Syntax

object.Object[.property |.method]

The Object property syntax has these parts:

Part | Description
object | Required. The name of an object you have added to the Microsoft Forms Toolbox.
property | Optional. A property that has the same name as a standard Microsoft Forms property.
method | Optional. A method that has the same name as a standard Microsoft Forms method.

Remarks

Object is read-only.

If you add a new control to the Microsoft Forms Toolbox, it is possible that the added control will have a property or method with the same name as a standard Microsoft Forms property or method. The Object property lets you use the property or method from the added control, rather than the standard property or method.


Orientation Property

Specifies whether the SpinButton or ScrollBar is oriented vertically or horizontally.

Syntax

object.Orientation [=Orientation]

The Orientation property syntax has these parts:

Part | Description
object | Required. A valid object.
Orientation | Optional. Orientation of the control.

Settings

The settings for Orientation are:

Value | Description
–1 | Automatically determines the orientation based upon the dimensions of the control (default).
0 | Control is rendered vertically.
1 | Control is rendered horizontally.

Remarks

If you specify automatic orientation, the height and width of the control determine whether it appears horizontally or vertically. For example, if the control is wider than it is tall, it appears horizontally; if it is taller than it is wide, the control appears vertically.


 Parent Property

Parent Property

Returns the name of the form, object, or collection that contains a specific control, object, or collection.

Syntax

object.Parent

The Parent property syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

Parent is read-only.

Use the Parent property to access the properties, methods, or controls of an object's parent.

This property is useful in an application in which you pass objects as arguments. For example, you could pass a control variable to a general procedure in a module, and use Parent to access its parent form.


 PasswordChar Property

PasswordChar Property

Specifies whether placeholder characters are displayed instead of the characters actually entered in a TextBox.

Syntax

object.PasswordChar [= String]

The PasswordChar property syntax has these parts:

Part | Description
object | Required. A valid object.
String | Optional. A string expression specifying the placeholder character.

Remarks

You can use the PasswordChar property to protect sensitive information, such as passwords or security codes. The value of PasswordChar is the character (usually an asterisk) that appears in a control instead of the actual characters that the user types. If you don't specify a character, the control displays the characters that the user types.


 Picture Property

Picture Property

Specifies the bitmap to display on an object.

Syntax

object.Picture = LoadPicture( pathname )

The Picture property syntax has these parts:

Part | Description
object | Required. A valid object.
pathname | Required. The full path to a picture file.

Remarks

You must use the control's property page to assign a bitmap to the Picture property. You cannot use the LoadPicture function to assign a bitmap to Picture.

To remove a picture that is assigned to a control, click the value of the Picture property in the property page and then press DELETE. Pressing BACKSPACE will not remove the picture.

Note For controls with captions, use the PicturePosition property to specify where to display the picture on the object. Use the PictureSizeMode property to determine how the picture fills the object.

Transparent pictures sometimes have a hazy appearance. If you do not like this appearance, display the picture on a control that supports opaque images. Image and MultiPage support opaque images.


 PictureAlignment Property

PictureAlignment Property

Specifies the location of a background picture.

Syntax

object.PictureAlignment [=PictureAlignment]

The PictureAlignment property syntax has these parts:

Part | Description
object | Required. A valid object.
PictureAlignment | Optional. The position where the picture aligns with the control.

Settings

The settings for PictureAlignment are:

Value | Description
0 | The top left corner.
1 | The top right corner.
2 | The center.
3 | The bottom left corner.
4 | The bottom right corner.

Remarks

The PictureAlignment property identifies which corner of the picture is the same as the corresponding corner of the control or container where the picture is used.

For example, setting PictureAlignment to 0 means that the top left corner of the picture coincides with the top left corner of the control or container. Setting PictureAlignment to 2 positions the picture in the middle, relative to the height as well as the width of the control or container.

If you tile an image on a control or container, the setting of PictureAlignment affects the tiling pattern. For example, if PictureAlignment is set to 0, the first copy of the image is laid in the upper left corner of the control or container and additional copies are tiled from left to right across each row. If PictureAlignment is 2, the first copy of the image is laid at the center of the control or container, additional copies are laid to the left and right to complete the row, and additional rows are added to fill the control or container.

Note Setting the PictureSizeMode property to 2 overrides PictureAlignment. When PictureSizeMode is set to 2, the picture fills the entire control or container.


PicturePosition Property

Specifies the location of the picture relative to its caption.

Syntax

object.PicturePosition [=PicturePosition]

The PicturePosition property syntax has these parts:

Part | Description
object | Required. A valid object.
PicturePosition | Optional. How the picture aligns with its container.

Settings

The settings for PicturePosition are:

Value | Description
0 | The picture appears to the left of the caption. The caption is aligned with the top of the picture.
1 | The picture appears to the left of the caption. The caption is centered relative to the picture.
2 | The picture appears to the left of the caption. The caption is aligned with the bottom of the picture.
3 | The picture appears to the right of the caption. The caption is aligned with the top of the picture.
4 | The picture appears to the right of the caption. The caption is centered relative to the picture.
5 | The picture appears to the right of the caption. The caption is aligned with the bottom of the picture.
6 | The picture appears above the caption. The caption is aligned with the left edge of the picture.
7 | The picture appears above the caption. The caption is centered below the picture (default).
8 | The picture appears above the caption. The caption is aligned with the right edge of the picture.
9 | The picture appears below the caption. The caption is aligned with the left edge of the picture.
10 | The picture appears below the caption. The caption is centered above the picture.
11 | The picture appears below the caption. The caption is aligned with the right edge of the picture.
12 | The picture appears in the center of the control. The caption is centered horizontally and vertically on top of the picture.

Remarks

The picture and the caption, as a unit, are centered on the control. If no caption exists, the picture's location is relative to the center of the control.

This property is ignored if the Picture property does not specify a picture.


 PictureSizeMode Property

PictureSizeMode Property

Specifies how to display the background picture on a control, form, or page.

Syntax

object.PictureSizeMode [=PictureSizeMode]

The PictureSizeMode property syntax has these parts:

Part | Description
object | Required. A valid object.
PictureSizeMode | Optional. The action to take if the picture and the form or page that contains it are not the same size.

Settings

The settings for PictureSizeMode are:

Value | Description
0 | Crops any part of the picture that is larger than the form or page (default).
1 | Stretches the picture to fill the form or page. This setting distorts the picture in either the horizontal or vertical direction.
3 | Enlarges the picture, but does not distort the picture in either the horizontal or vertical direction.

Remarks

The PictureSizeModeClip setting indicates you want to show the picture in its original size and scale. If the form or page is smaller than the picture, this setting only shows the part of the picture that fits within the form or page.

The 1 and 3 settings both enlarge the image, but 1 causes distortion. The 1 setting enlarges the image horizontally and vertically until the image reaches the corresponding edges of the container or control. The 3 setting enlarges the image until it reaches either the horizontal or vertical edges of the container or control. If the image reaches the horizontal edges first, any remaining distance to the vertical edges remains blank. If it reaches the vertical edges first, any remaining distance to the horizontal edges remains blank.

Note Setting the PictureSizeMode property to 2 overrides PictureAlignment. When PictureSizeMode is set to 2, the picture fills the entire control or container.


PictureTiling Property

Lets you tile a picture in a form or page.

Syntax

object.PictureTiling [= Boolean]

The PictureTiling property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether a picture is repeated across a background.

Settings

The settings for Boolean are:

Value | Description
True | The picture is tiled across the background.
False | The picture is not tiled across the background (default).

Remarks

If a picture is smaller than the form or page that contains it, you can tile the picture on the form or page.

The tiling pattern depends on the current setting of the PictureAlignment and PictureSizeMode properties. For example, if PictureAlignment is set to 0, the tiling pattern starts at the upper left and repeats the picture across the form or page and down the height of the form or page. If PictureSizeMode is set to 0, the tiling pattern crops the last tile if it doesn't completely fit on the form or page.


ProportionalThumb Property

Specifies whether the size of the scroll box is proportional to the scrolling region or fixed.

Syntax

object.ProportionalThumb [= Boolean]

The ProportionalThumb property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the scroll box is proportional or fixed.

Settings

The settings for Boolean are:

Value | Description
True | The scroll box is proportional in size to the scrolling region (default).
False | The scroll box is a fixed size.

Remarks

The size of a proportional scroll box graphically represents the percentage of the object that is visible in the window. For example, if 75 percent of an object is visible, the scroll box covers three-fourths of the scrolling region in the scroll bar.

If the scroll box is a fixed size, the system determines its size based on the height and width of the scroll bar.


RowSource Property

Specifies the source providing a list for a ComboBox or ListBox.

Syntax

object.RowSource [= String]

The RowSource property syntax has these parts:

Part | Description
object | Required. A valid object.
String | Optional. The source of the list for the ComboBox or ListBox.

Remarks

The RowSource property accepts worksheet ranges from Microsoft Excel.


ScrollBars Property

Specifies whether a control, form, or page has vertical scroll bars, horizontal scroll bars, or both.

Syntax

object.ScrollBars [=ScrollBars]

The ScrollBars property syntax has these parts:

Part | Description
object | Required. A valid object.
ScrollBars | Optional. Where scroll bars should be displayed.

Settings

The settings for ScrollBars are:

Value | Description
0 | Displays no scroll bars (default).
1 | Displays a horizontal scroll bar.
2 | Displays a vertical scroll bar.
3 | Displays both a horizontal and a vertical scroll bar.

Remarks

If the KeepScrollBarsVisible property is True, any scroll bar on a form or page is always visible, regardless of whether the object's contents fit within the object's borders.

If visible, a scroll bar constrains its scroll box to the visible region of the scroll bar. It also modifies the scroll position as needed to keep the entire scroll bar visible. The range of a scroll bar changes when the value of the ScrollBars property changes, the scroll size changes, or the visible size changes.

If a scroll bar is not visible, then you can set its scroll position to any value. Negative values and values greater than the scroll size are both valid.

For a single-line control, you can display a horizontal scroll bar by using the ScrollBars and AutoSize properties. Scroll bars are hidden or displayed according to the following rules:

  1. When ScrollBars is set to ScrollBarsNone, no scroll bar is displayed.

  2. When ScrollBars is set to 1 or 3, the control displays a horizontal scroll bar if the text is longer than the edit region and if the control has enough room to include the scroll bar underneath its edit region.

  3. When AutoSize is True, the control enlarges itself to accommodate the addition of a scroll bar unless the control is at or near its maximum size.

For a multiline TextBox, you can display scroll bars by using the ScrollBars, WordWrap, and AutoSize properties. Scroll bars are hidden or displayed according to the following rules:

  1. When ScrollBars is set to 0, no scroll bar is displayed.

  2. When ScrollBars is set to 2 or 3, the control displays a vertical scroll bar if the text is longer than the edit region and if the control has enough room to include the scroll bar at the right edge of its edit region.

  3. When WordWrap is True, the multiline control will not display a horizontal scroll bar. Most multiline controls do not use a horizontal scroll bar.

  4. A multiline control can display a horizontal scroll bar if the following conditions occur simultaneously:
    • The edit region contains a word that is longer than the edit region's width.

    • The control has enabled horizontal scroll bars.

    • The control has enough room to include the scroll bar under the edit region.

    • The WordWrap property is set to False.


 ScrollHeight, ScrollWidth Properties

ScrollHeight, ScrollWidth Properties

Specify the height, in points, of the total area that can be viewed by moving the scroll bars on the control, form, or page.

Syntax

object.ScrollHeight [= Single]

object.ScrollWidth [= Single]

The ScrollHeight and ScrollWidth property syntaxes have these parts:

Part | Description
object | Required. A valid object.
Single | Optional. The height or width of the scrollable region.


 ScrollLeft, ScrollTop Properties

ScrollLeft, ScrollTop Properties

Specify the distance, in points, of the left or top edge of the visible form from the left or top edge of the logical form, page, or control.

Syntax

object.ScrollLeft [= Single]

object.ScrollTop [= Single]

The ScrollLeft and ScrollTop property syntaxes have these parts:

Part | Description
object | Required. A valid object.
Single | Optional. The distance from the edge of the form.

Remarks

The minimum value is zero; the maximum value is the difference between the value of the ScrollWidth property and the value of the Width property for the form or page.


 Selected Property

Selected Property

Returns or sets the selection state of items in a ListBox.

Syntax

object.Selected( index ) [= Boolean]

The Selected property syntax has these parts:

Part | Description
object | Required. A valid object.
index | Required. An integer with a range from 0 to one less than the number of items in the list.
Boolean | Optional. Whether an item is selected.

Settings

The settings for Boolean are:

Value | Description
True | The item is selected.
False | The item is not selected.

Remarks

The Selected property is useful when users can make multiple selections. You can use this property to determine the selected rows in a multi-select list box. You can also use this property to select or deselect rows in a list from code.

The default value of this property is based on the current selection state of the ListBox.

For single-selection list boxes, the Value or ListIndex properties are recommended for getting and setting the selection. In this case, ListIndex returns the index of the selected item. However, in a multiple selection, ListIndex returns the index of the row contained within the focus rectangle, regardless of whether the row is actually selected.

When a list box control's MultiSelect property is set to None, only one row can have its Selected property set to True.

Entering a value that is out of range for the index does not generate an error message, but does not set a property for any item in the list.


SelectedItem Property

Returns the currently selected Tab or Page object.

Syntax

object.SelectedItem

The SelectedItem property syntax has these parts:

Part | Description
object | Required. A valid TabStrip or MultiPage.

Remarks

The SelectedItem property is read-only. Use SelectedItem to programmatically control the currently selected Tab or Page object. For example, you can use SelectedItem to assign values to properties of a Tab or Page object.


SelectionMargin Property

Specifies whether the user can select a line of text by clicking in the region to the left of the text.

Syntax

object.SelectionMargin [= Boolean]

The SelectionMargin property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether clicking in the margin selects a line of text.

Settings

The settings for Boolean are:

Value | Description
True | Clicking in margin causes selection of text (default).
False | Clicking in margin does not cause selection of text.

Remarks

When the SelectionMargin property is True, the selection margin occupies a thin strip along the left edge of a control's edit region. When set to False, the entire edit region can store text.

If the SelectionMargin property is set to True when a control is printed, the selection margin also prints.


 SelLength Property

SelLength Property

The number of characters selected in a TextBox or the text portion of a ComboBox.

Syntax

object.SelLength [= Long]

The SelLength property syntax has these parts:

Part | Description
object | Required. A valid object.
Long | Optional. A numeric expression specifying the number of characters selected. For SelLength and SelStart, the valid range of settings is 0 to the total number of characters in the edit area of a ComboBox or TextBox.

Remarks

The SelLength property is always valid, even when the control does not have focus. Setting SelLength to a value less than zero creates an error. Attempting to set SelLength to a value greater than the number of characters available in a control results in a value equal to the number of characters in the control.

Note Changing the value of the SelStart property cancels any existing selection in the control, places an insertion point in the text, and sets SelLength to zero.

The default value, zero, means that no text is currently selected.


 SelStart Property

SelStart Property

Indicates the starting point of selected text, or the insertion point if no text is selected.

Syntax

object.SelStart [= Long]

The SelStart property syntax has these parts:

Part | Description
object | Required. A valid object.
Long | Optional. A numeric expression specifying the starting point of text selected. For SelLength and SelStart, the valid range of settings is 0 to the total number of characters in the edit area of a ComboBox or TextBox. The default value is zero.

Remarks

The SelStart property is always valid, even when the control does not have focus. Setting SelStart to a value less than zero creates an error. Attempting to set SelStart to a value greater than the number of characters available in a control results in a value equal to the number of characters in the control.

Changing the value of SelStart cancels any existing selection in the control, places an insertion point in the text, and sets the SelLength property to zero.


 SelText Property

SelText Property

Returns or sets the selected text of a control.

Syntax

object.SelText [= String]

The SelText property syntax has these parts:

Part | Description
object | Required. A valid object.
String | Optional. A string expression containing the selected text.

Remarks

If no characters are selected in the edit region of the control, the SelText property returns a zero length string. This property is valid regardless of whether the control has the focus.


ShowDropButtonWhen Property

Specifies when to show the drop-down button for a ComboBox.

Syntax

object.ShowDropButtonWhen [=ShowDropButtonWhen]

The ShowDropButtonWhen property syntax has these parts:

Part | Description
object | Required. A valid object.
ShowDropButtonWhen | Optional. The circumstances under which the drop-down button will be visible.

Settings

The settings for ShowDropButtonWhen are:

Value | Description
0 | Do not show the drop-down button under any circumstances.
1 | Show the drop-down button when the control has the focus.
2 | Always show the drop-down button.

For a ComboBox, the default value is 2.


SmallChange Property

Specifies the amount of movement that occurs when the user clicks either scroll arrow in a ScrollBar or SpinButton.

Syntax

object.SmallChange [= Long]

The SmallChange property syntax has these parts:

Part | Description
object | Required. A valid object.
Long | Optional. An integer that specifies the amount of change to the Value property.

Remarks

The SmallChange property does not have units.

Any integer is an acceptable setting for this property. The recommended range of values is from –32,767 to +32,767. The default value is 1.


 SpecialEffect Property

SpecialEffect Property

Specifies the visual appearance of an object.

Syntax

object.SpecialEffect [=SpecialEffect]

The SpecialEffect property syntax has these parts:

Part | Description
object | Required. A valid object.
SpecialEffect | Optional. The desired visual appearance of an object other than a CheckBox, OptionButton, or ToggleButton.

Settings

The settings for SpecialEffect are:

Value | Description
0 | Object appears flat, distinguished from the surrounding form by a border, a change of color, or both. Default for Image and Label, valid for all controls.
1 | Object has a highlight on the top and left and a shadow on the bottom and right. Not valid for check boxes or option buttons.
2 | Object has a shadow on the top and left and a highlight on the bottom and right. The control and its border appear to be carved into the form that contains them. Default for CheckBox and OptionButton, valid for all controls (default).
3 | Border appears to be carved around the edge of the control. Not valid for check boxes or option buttons.
6 | Object has a ridge on the bottom and right and appears flat on the top and left. Not valid for check boxes or option buttons.

For a Frame, the default value is 2.

Note that only 0 and 2 are acceptable values for CheckBox, OptionButton, and ToggleButton. All values listed are acceptable for other controls.

Remarks

You can use either the SpecialEffect or the BorderStyle property to specify the edging for a control, but not both. If you specify a nonzero value for one of these properties, the system sets the value of the other property to zero. For example, if you set SpecialEffect to 1, the system sets BorderStyle to 0.

For a Frame, BorderStyle is ignored if SpecialEffect is 0.

SpecialEffect uses the system colors to define its borders.

Note Although the SpecialEffect property exists on the ToggleButton, the property is disabled. You cannot set or return a value for this property on the ToggleButton.


Style Property

For ComboBox, specifies how the user can choose or set the control's value. For MultiPage and TabStrip, identifies the style of the tabs on the control.

Syntax

object.Style [=Style]

The Style property syntax has these parts:

Part | Description
object | Required. A valid object.
Style | Optional. Specifies how a user sets the value of a ComboBox.

Settings

The settings for ComboBox are:

Value | Description
0 | The ComboBox behaves as a drop-down combo box. The user can type a value in the edit region or select a value from the drop-down list (default).
2 | The ComboBox behaves as a list box. The user must choose a value from the list.

The settings for MultiPage and TabStrip are::

Value | Description
0 | Displays tabs on the tab bar (default).
1 | Displays buttons on the tab bar.
2 | Does not display the tab bar.


 TabFixedHeight, TabFixedWidth Properties

TabFixedHeight, TabFixedWidth Properties

Sets or returns the fixed height or width of the tabs in points.

Syntax

object.TabFixedHeight [= Single]

object.TabFixedWidth [= Single]

The TabFixedHeight and TabFixedWidth property syntaxes have these parts:

Part | Description
object | Required. A valid object.
Single | Optional. The number of points of the height or width of the tabs on a TabStrip or MultiPage.

Settings

If the value is 0, tab widths are automatically adjusted so that each tab is wide enough to accommodate its contents and each row of tabs spans the width of the control.

If the value is greater than 0, all tabs have an identical width as specified by this property.

Remarks

The minimum size is 4 points.


 TabIndex Property

TabIndex Property

Specifies the position of a single object in the form's tab order.

Syntax

object.TabIndex [= Integer]

The TabIndex property syntax has these parts:

Part | Description
object | Required. A valid object.
Integer | Optional. An integer from 0 to one less than the number of controls on the form that have a TabIndex property. Assigning a TabIndex value of less than 0 generates an error. If you assign a TabIndex value greater than the largest index value, the system resets the value to the maximum allowable value.

Remarks

The index value of the first object in the tab order is zero.


 TabKeyBehavior Property

TabKeyBehavior Property

Determines whether tabs are allowed in the edit region.

Syntax

object.TabKeyBehavior [= Boolean]

The TabKeyBehavior property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. The effect of pressing TAB.

Settings

The settings for Boolean are:

Value | Description
True | Pressing TAB inserts a tab character in the edit region.
False | Pressing TAB moves the focus to the next object in the tab order (default).

Remarks

The TabKeyBehavior and MultiLine properties are closely related. The values described above only apply if MultiLine is True. If MultiLine is False, pressing TAB always moves the focus to the next control in the tab order regardless of the value of TabKeyBehavior.

The effect of pressing CTRL+TAB also depends on the value of MultiLine. If MultiLine is True, pressing CTRL+TAB creates a new line regardless of the value of TabKeyBehavior. If MultiLine is False, pressing CTRL+TAB has no effect.


TabOrientation Property

Specifies the location of the tabs on a MultiPage or TabStrip.

Syntax

object.TabOrientation [=TabOrientation]

The TabOrientation property syntax has these parts:

Part | Description
object | Required. A valid object.
TabOrientation | Optional. Where the tabs will appear.

Settings

The settings for TabOrientation are:

Value | Description
0 | The tabs appear at the top of the control (default).
1 | The tabs appear at the bottom of the control.
2 | The tabs appear at the left side of the control.
3 | The tabs appear at the right side of the control.

Remarks

If you use TrueType fonts, the text rotates when the TabOrientation property is set to 2 or 3. If you use bitmapped fonts, the text does not rotate.


 TabStop Property

TabStop Property

Indicates whether an object can receive focus when the user tabs to it.

Syntax

object.TabStop [= Boolean]

The TabStop property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the object is a tab stop.

Settings

The settings for Boolean are:

Value | Description
True | Designates the object as a tab stop (default).
False | Bypasses the object when the user is tabbing, although the object still holds its place in the actual tab order, as determined by the TabIndex property.

Remarks

You can combine the settings of the Enabled and the TabStop properties to prevent the user from selecting a command button with TAB, while still allowing the user to click the button. Setting TabStop to False means that the command button won't appear in the tab order. However, if Enabled is True, then the user can still click the command button, as long as TakeFocusOnClick is set to True.

When the user tabs into an enabled MultiPage or TabStrip, the first page or tab in the control receives the focus. If the first page or tab of a MultiPage or TabStrip is disabled, the first enabled page or tab of that control receives the focus. If all pages or tabs of a MultiPage or TabStrip are disabled, the control is disabled and cannot receive the focus.


Tag Property

Stores additional information about an object.

Syntax

object.Tag [= String]

The Tag property syntax has these parts:

Part | Description
object | Required. A valid object.
String | Optional. A string expression identifying the object. The default is a zero-length string ("").

Remarks

Use the Tag property to assign an identification string to an object without affecting other property settings or attributes.

For example, you can use Tag to check the identity of a form or control that is passed as a variable to a procedure.


 TakeFocusOnClick Property

TakeFocusOnClick Property

Specifies whether a control takes the focus when clicked.

Syntax

object.TakeFocusOnClick [= Boolean]

The TakeFocusOnClick property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Specifies whether a control takes the focus when clicked.

Settings

The settings for Boolean are:

Value | Description
True | The button takes the focus when clicked (default).
False | The button does not take the focus when clicked.

Remarks

The TakeFocusOnClick property defines only what happens when the user clicks a control. If the user tabs to the control, the control takes the focus regardless of the value of TakeFocusOnClick.

Use this property to complete actions that affect a control without requiring that control to give up focus. For example, assume your form includes a TextBox and a CommandButton that checks for correct spelling of text. You would like to be able to select text in the TextBox, then click the CommandButton and run the spelling checker without taking focus away from the TextBox. You can do this by setting the TakeFocusOnClick property of the CommandButton to False.


Text Property

Returns or sets the text in a TextBox. Changes the selected row in a ComboBox or ListBox.

Syntax

object.Text [= String]

The Text property syntax has these parts:

Part | Description
object | Required. A valid object.
String | Optional. A string expression specifying text. The default value is a zero-length string ("").

Remarks

For a TextBox, any value you assign to the Text property is also assigned to the Value property.

For a ComboBox, you can use Text to update the value of the control. If the value of Text matches an existing list entry, the value of the ListIndex property (the index of the current row) is set to the row that matches Text. If the value of Text does not match a row, ListIndex is set to –1.

For a ListBox, the value of Text must match an existing list entry. Specifying a value that does not match an existing list entry causes an error.

When the Text property of a ComboBox changes (such as when a user types an entry into the control), the new text is compared to the column of data specified by TextColumn.

You cannot use Text to change the value of an entry in a ComboBox or ListBox; use the Column or List property for this purpose.

The ForeColor property determines the color of the text.


TextAlign Property

Specifies how text is aligned in a control.

Syntax

object.TextAlign [=TextAlign]

The TextAlign property syntax has these parts:

Part | Description
object | Required. A valid object.
TextAlign | Optional. How text is aligned in the control.

Settings

The settings for TextAlign are:

Value | Description
1 | Aligns the first character of displayed text with the left edge of the control's display or edit area (default).
2 | Centers the text in the control's display or edit area.
3 | Aligns the last character of displayed text with the right edge of the control's display or edit area.

Remarks

For a ComboBox, the TextAlign property only affects the edit region; this property has no effect on the alignment of text in the list. For stand-alone labels, TextAlign determines the alignment of the label's caption.


TextColumn Property

Identifies the column in a ComboBox or ListBox to display to the user.

Syntax

object.TextColumn [= Variant]

The TextColumn property syntax has these parts:

Part | Description
object | Required. A valid object.
Variant | Optional. The column to be displayed.

Settings

Values for the TextColumn property range from –1 to the number of columns in the list. The TextColumn value for the first column is 1, the value of the second column is 2, and so on. Setting TextColumn to 0 displays the ListIndex values. Setting TextColumn to –1 displays the first column that has a ColumnWidths value greater than 0.

Remarks

When the user selects a row from a ComboBox or ListBox, the column referenced by TextColumn is stored in the Text property.For example, you could set up a multicolumn ListBox that contains the names of holidays in one column and dates for the holidays in a second column. To present the holiday names to users, specify the first column as the TextColumn. To store the dates of the holidays, specify the second column as the BoundColumn.

When the Text property of a ComboBox changes (such as when a user types an entry into the control), the new text is compared to the column of data specified by TextColumn.


TextLength Property

Returns the length, in characters, of text in the edit region of a TextBox or ComboBox.

Syntax

object.TextLength

The TextLength property syntax has these parts:

Part | Description
object | Required. A valid object.

Remarks

The TextLength property is read-only. For a multiline TextBox, TextLength includes LF (line feed) and CR (carriage return) characters.


TopIndex Property

Sets and returns the item that appears in the topmost position in the list.

Syntax

object.TopIndex [= Variant]

The TopIndex property syntax has these parts:

Part | Description
object | Required. A valid object.
Variant | Optional. The number of the list item that is displayed in the topmost position. The default is 0, or the first item in the list.

Settings

Returns the value –1 if the list is empty or not displayed.


 TripleState Property

TripleState Property

Determines whether a user can specify, from the user interface, the Null state for a CheckBox or ToggleButton.

Syntax

object.TripleState [= Boolean]

The TripleState property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the control supports the Null state.

Settings

The settings for Boolean are:

Value | Description
True | The button clicks through three states.
False | The button only supports True and False (default).

Remarks

Although the TripleState property exists on the OptionButton, the property does not affect the action of the control. Regardless of the value of TripleState, you cannot set the control to Null through the user interface.

When the TripleState property is True, a user can choose from the values of Null, True, and False. The null value is displayed as a shaded button.

When TripleState is False, the user can choose either True or False.

A control set to Null does not initiate the Click event.

Regardless of the property setting, the Null value can always be assigned programmatically to an OptionButton, CheckBox or ToggleButton, causing that control to appear shaded.


 Value Property

Value Property

Specifies the state or content of a given control.

Syntax

object.Value [= Variant]

The Value property syntax has these parts:

Part | Description
object | Required. A valid object.
Variant | Optional. The state or content of the control.

Settings

Control | Description
CheckBox | An integer value indicating whether the item is selected:
 | Null Indicates the item is in a null state, neither selected nor cleared.
 | –1 True. Indicates the item is selected.
 | 0 False. Indicates the item is cleared.
OptionButton | Same as CheckBox.
ToggleButton | Same as CheckBox.
ScrollBar | An integer between the values specified for the Max and Min properties.
SpinButton | Same as ScrollBar.
ComboBox , ListBox | The value in the BoundColumn of the currently selected rows.
CommandButton | Always False.
MultiPage | An integer indicating the currently active page.
 | Zero (0) indicates the first page. The maximum value is one less than the number of pages.
TextBox | The text in the edit region.

Remarks

For a CommandButton, setting the Value property to True in a macro or procedure initiates the button's Click event.

For a ComboBox, changing the contents of Value does not change the value of BoundColumn. To add or delete entries in a ComboBox, you can use the AddItem or RemoveItem method.

For a TextBox, any value you assign to the Text property is also assigned to the Value property.

Value cannot be used with a multi-select ListBox.


VerticalScrollBarSide Property

Specifies whether a vertical scroll bar appears on the right or left side of a frame.

Syntax

object.VerticalScrollBarSide [= VerticalScrollBarSide]

The VerticalScrollBarSide property syntax has these parts:

Part | Description
object | Required. A valid object.
VerticalScrollBarSide | Optional. Where the scroll bar should appear.

Settings

Value | Description
0 | Puts the scroll bar on the right side (default).
1 | Puts the scroll bar on the left side.


 Visible Property

Visible Property

Specifies whether an object is visible or hidden.

Syntax

object.Visible [= Boolean]

The Visible property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the object is visible or hidden.

Settings

The settings for Boolean are:

Value | Description
True | Object is visible (default).
False | Object is hidden.

Remarks

Use the Visible property to control access to information without displaying it. For example, you could use the value of a control on a hidden form as the criteria for a query.

All controls are visible at design time.


WordWrap Property

Indicates whether the contents of a control automatically wrap at the end of a line.

Syntax

object.WordWrap [= Boolean]

The WordWrap property syntax has these parts:

Part | Description
object | Required. A valid object.
Boolean | Optional. Whether the control expands to fit the text.

Settings

The settings for Boolean are:

Value | Description
True | The text wraps (default).
False | The text does not wrap.

Remarks

For controls that support the MultiLine property as well as the WordWrap property, WordWrap is ignored when MultiLine is False.


Zoom Property

Specifies how much to change the size of a displayed object.

Syntax

object.Zoom [= Integer]

The Zoom property syntax has these parts:

Part | Description
object | Required. A valid object.
Integer | The percentage to increase or decrease the displayed image.

Remarks

The value of the Zoom property specifies a percentage of image enlargement or reduction by which an image display should change. Values from 10 to 400 are valid. The value specified is a percentage of the object’s original size; thus, a setting of 400 means you want to enlarge the image to four times its original size (or 400 percent), while a setting of 10 means you want to reduce the image to one-tenth of its original size (or 10 percent).


Microsoft Outlook Objects

Application object

PropertyPages collection (PropertyPage object)
SyncObjects collection (SyncObject object)
AddressLists collection (AddressList object)
AddressEntries collection (AddressEntry object)
Folders collection (MAPIFolder object)
Items collection (Item object)
Links colleciton (Link object)
UserProperties collection (UserProperty object)

Actions collection (Action object)
Attachments collection (Attachment object)
Recipients collection (Recipient object)

Exceptions collection (Exception object)
PropertyPages collection (PropertyPage object)

Legend

yellow box Object and collection
bluebox Object only
COMAddIns collection (COMAddIn object)
Explorers collection (Explorer object)
Selection collection (Items object)

CommandBars collection (CommandBar object)
Panes collection (Pane object)

OutlookBarGroups collection (OutlookBarGroup object)
OutlookBarShortcuts collection (OutlookBarShortcut object)
Inspectors collection (Inspector object)

Pages collection (Page object)
CommandBars collection (CommandBar object)


Microsoft Outlook Constants

When you automate Microsoft Outlook by using an Automation object in an application that supports Visual Basic for Applications, you can use built-in constants to specify property and argument values.

However, when you automate Microsoft Outlook by using VBScript, you must use the numeric values that the constants represent. The following lists the built-in Microsoft Outlook constant enumerations. Click the name of the enumeration to see its constants and their values.

OlActionCopyLike

OlActionReplyStyle

OlActionResponseStyle

OlActionShowOn

OlAttachmentType

OlBusyStatus

OlDaysOfWeek

OlDefaultFolders

OlDisplayType

OlEditorType

OlFlagStatus

OlFolderDisplayMode

OlFormRegistry

OlGender

OlImportance

OlInspectorClose

OlItemType

OlJournalRecipientType

OlMailingAddress

OlMailRecipientType

OlMeetingRecipientType

OlMeetingStatus

 OlNetMeetingType

OlNoteColor

OlObjectClass

OlOutlookBarViewType

OlPane

OlRecurrenceState

OlMeetingResponse

OlRecurrenceType

OlRemoteStatus

OlResponseStatus

OlSaveAsType

OlSensitivity

OlSortOrder

OlSyncState

OlTaskDelegationStatus

OlTaskOwnership

OlTaskRecipientType

OlTaskResponse

OlTaskStatus

OlTrackingStatus

OlUserPropertyType

OlWindowState


OLE Programmatic Identifiers

You can use an OLE programmatic identifier (sometimes called a ProgID) to create an Automation object. The following tables list OLE programmatic identifiers for ActiveX controls, Microsoft Office applications, and Microsoft Office Web Components.

ActiveX Controls

Microsoft Access

Microsoft Excel

Microsoft Graph

Microsoft Office Web Components

Microsoft Outlook

Microsoft PowerPoint

Microsoft Word

ActiveX Controls

To create the ActiveX controls listed in the following table, use the corresponding OLE programmatic identifier.

To create this control | Use this identifier
CheckBox | Forms.CheckBox.1
ComboBox | Forms.ComboBox.1
CommandButton | Forms.CommandButton.1
Frame | Forms.Frame.1
Image | Forms.Image.1
Label | Forms.Label.1
ListBox | Forms.ListBox.1
MultiPage | Forms.MultiPage.1
OptionButton | Forms.OptionButton.1
ScrollBar | Forms.ScrollBar.1
SpinButton | Forms.SpinButton.1
TabStrip | Forms.TabStrip.1
TextBox | Forms.TextBox.1
ToggleButton | Forms.ToggleButton.1

Microsoft Access

To create the Microsoft Access objects listed in the following table, use one of the corresponding OLE programmatic identifiers. If you use an identifier without a version number suffix, you create an object in the most recent version of Access available on the machine where the macro is running.

To create this object | Use one of these identifiers
Application | Access.Application, Access.Application.9
CurrentData | Access.CodeData, Access.CurrentData
CurrentProject | Access.CodeProject, Access.CurrentProject
DefaultWebOptions | Access.DefaultWebOptions

Microsoft Excel

To create the Microsoft Excel objects listed in the following table, use one of the corresponding OLE programmatic identifiers. If you use an identifier without a version number suffix, you create an object in the most recent version of Excel available on the machine where the macro is running.

To create this object | Use one of these identifiers | Comments
Application | Excel.Application, Excel.Application.9 |
Workbook | Excel.AddIn |
Workbook | Excel.Chart, Excel.Chart.8 | Returns a workbook containing two worksheets; one for the chart and one for its data. The chart worksheet is the active worksheet.
Workbook | Excel.Sheet, Excel.Sheet.8 | Returns a workbook with one worksheet.

Microsoft Graph

To create the Microsoft Graph objects listed in the following table, use one of the corresponding OLE programmatic identifiers. If you use an identifier without a version number suffix, you create an object in the most recent version of Graph available on the machine where the macro is running.

To create this object | Use one of these identifiers
Application | MSGraph.Application, MSGraph.Application.8
Chart | MSGraph.Chart, MSGraph.Chart.8

Microsoft Office Web Components

To create the Microsoft Office Web Components objects listed in the following table, use one of the corresponding OLE programmatic identifiers. If you use an identifier without a version number suffix, you create an object in the most recent version of Microsoft Office Web Components available on the machine where the macro is running.

To create this object | Use one of these identifiers
ChartSpace | OWC.Chart, OWC.Chart.9
DataSourceControl | OWC.DataSourceControl, OWC.DataSourceControl.9
ExpandControl | OWC.ExpandControl, OWC.ExpandControl.9
PivotTable | OWC.PivotTable, OWC.PivotTable.9
RecordNavigationControl | OWC.RecordNavigationControl, OWC.RecordNavigationControl.9
Spreadsheet | OWC.Spreadsheet, OWC.Spreadsheet.9

Microsoft Outlook

To create the Microsoft Outlook object given in the following table, use one of the corresponding OLE programmatic identifiers. If you use an identifier without a version number suffix, you create an object in the most recent version of Outlook available on the machine where the macro is running.

To create this object | Use one of these identifiers
Application | Outlook.Application, Outlook.Application.9

Microsoft PowerPoint

To create the Microsoft PowerPoint object givenin the following table, use one of the corresponding OLE programmatic identifiers. If you use an identifier without a version number suffix, you create an object in the most recent version of PowerPoint available on the machine where the macro is running.

To create this object | Use one of these identifiers
Application | PowerPoint.Application, PowerPoint.Application.9

Microsoft Word

To create the Microsoft Word objects listed in the following table, use one of the corresponding OLE programmatic identifiers. If you use an identifier without a version number suffix, you create an object in the most recent version of Word available on the machine where the macro is running.

To create this object | Use one of these identifiers
Application | Word.Application, Word.Application.9
Document | Word.Document, Word.Document.9, Word.Template.8
Global | Word.Global


Activate Event

Occurs when an explorer or inspector becomes the active window, either as a result of user action or through program code. This event is not available in VBScript.

Syntax

Sub object_Activate()

object An expression that evaluates to an Explorer or Inspector object.


AttachmentAdd Event

Occurs when an attachment has been added to an item.

Syntax

Sub Item_AttachmentAdd(NewAttachment as Attachment)

NewAttachment Required. The Attachment that was added to the item.


AttachmentRead Event

Occurs when an attachment in an item has been opened for reading.

Syntax

Sub Item_AttachmentRead(Attachment as Attachment)

Attachment Required. The Attachment that was opened.


BeforeAttachmentSave Event

Occurs just before an attachment is saved.

Syntax 1

Function Item_BeforeAttachmentSave(byVal Attachment)

Syntax 2

Sub object_BeforeAttachmentSave(Attachment as Attachment, Cancel as Boolean)

object An expression that evaluates to an object in the “Applies To” list.

Attachment Required. The Attachment to be saved.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the save operation is not completed and the attachment is not changed.

Remarks

Use Syntax 1 in VBScript. If you set the return value of this function to False, the save operation is cancelled and the attachment is not changed.

Use Syntax 2 when handling the BeforeAttachmentSave event in Microsoft Visual Basic or Microsoft Visual Basic for Applications.


BeforeCheckNames Event

Occurs just before Microsoft Outlook starts resolving names in the recipient collection for an item.

Syntax 1

Function Item_BeforeCheckNames()

Syntax 2

Sub object_BeforeCheckNames(Cancel as Boolean)

object An expression that evaluates to an object in the Applies To list.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the operation is cancelled and the names in the recipients collection are not resolved.

Remarks

Use Syntax 1 in VBScript. If you set the return value of this function to False, the operation is cancelled and the names in the recipients collection are not resolved.

Use Syntax 2 when handling the BeforeCheckNames event in Microsoft Visual Basic or Microsoft Visual Basic for Applications.


BeforeFolderSwitch Event

Occurs before the explorer navigates to a new folder, either as a result of user action or through program code. This event is not available in VBScript.

Note If the folder being switched to is in a name space that doesn’t support Automation (such as the file system), NewFolder is Nothing.

Syntax

Sub object_BeforeFolderSwitch(NewFolder as Object, Cancel as Boolean)

object An expression that evaluates to an Explorer object.

NewFolder Required. The MAPIFolder object the explorer is switching to.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, navigation is cancelled and the current folder is not changed.


 BeforeGroupAdd Event

BeforeGroupAdd Event

Occurs before a new group is added to the Outlook Bar, either as a result of user action or through program code. This event is not available in VBScript.

Syntax

Sub object_BeforeGroupAdd(Cancel as Boolean)

object An expression that evaluates to an OutlookBarGroups collection object.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the group is not added to the Outlook Bar.


 BeforeGroupRemove Event

BeforeGroupRemove Event

Occurs before a new group is removed from the Outlook Bar, either as a result of user action or through program code. This event is not available in VBScript.

Syntax

Sub object_BeforeGroupRemove(Group as OutlookBarGroup, Cancel as Boolean)

object An expression that evaluates to an OutlookBarGroups collection object.

Group Required. The OutlookBarGroup that is being removed.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the group is not removed from the Outlook Bar.


 BeforeGroupSwitch Event

BeforeGroupSwitch Event

Occurs before a new group is opened in the Outlook Bar, either as a result of user action or through program code. This event is not available in VBScript.

Syntax

Sub object_BeforeGroupSwitch(Group as OutlookBarGroup, Cancel as Boolean)

object An expression that evaluates to an OutlookBarPane object.

Group Required. The OutlookBarGroup being opened.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the change is cancelled and the current group remains open.


 BeforeNavigate Event

BeforeNavigate Event

Occurs when the user clicks on an Outlook Bar shortcut to navigate to a different folder. This event is not available in VBScript.

Syntax

Sub object_BeforeNavigate(Shortcut as OutlookBarShortcut, Cancel as Boolean)

object An expression that evaluates to an OutlookBarPane object.

Shortcut Required. The shortcut that the user clicked.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the current folder is not changed.


 BeforeShortcutAdd Event

BeforeShortcutAdd Event

Occurs before a new shortcut is added to a group in the Outlook Bar, either as a result of user action or through program code. This event is not available in VBScript.

Syntax

Sub object_BeforeShortcutAdd(Cancel as Boolean)

object An expression that evaluates to an OutlookBarShortcuts collection object.

NewShortcut Required. The OutlookBarShortcut that is being added.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the shortcut is not added to the group.


 BeforeShortcutRemove Event

BeforeShortcutRemove Event

Occurs before a new shortcut is removed from a group in the Outlook Bar, either as a result of user action or through program code. This event is not available in VBScript.

Syntax

Sub object_BeforeShortcutRemove(Shortcut as OutlookBarShortcut, Cancel as Boolean)

object An expression that evaluates to an OutlookBarShortcuts collection object.

Shortcut Required. The OutlookBarShortcut that is being removed.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the shortcut is not removed from the group.


 BeforeViewSwitch Event

BeforeViewSwitch Event

Occurs before the explorer changes to a new view, either as a result of user action or through program code. This event is not available in VBScript.

Syntax

Sub object_BeforeViewSwitch(NewView as String, Cancel as Boolean)

object An expression that evaluates to an Explorer object.

NewView Required. The name of the view the explorer is switching to.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the switch is cancelled and the current view is not changed.


 Close Event

Close Event

Occurs when the Inspector associated with an Outlook item is being closed.

Syntax 1

Function Item_Close()

Syntax 2

Sub object_Close(Cancel as Boolean)

object An expression that evaluates to an object in the “Applies To” list.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the close operation is not completed and the inspector is left open.

Remarks

Use Syntax 1 in VBScript. If you set the return value of this function to False, the close operation isn't completed and the inspector is left open.

Use Syntax 2 when handling the Close event in Visual Basic or Visual Basic for Applications.


 CustomAction Event

CustomAction Event

Occurs when a custom action of an Outlook item executes. The Action object and the newly-created item resulting from the custom action are passed to the event.

Syntax 1

Function Item_CustomAction()

Syntax 2

Sub object_CustomAction(Cancel as Boolean)

object An expression that evaluates to an object in the “Applies To” list.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the custom action is not completed.

Remarks

Use Syntax 1 in VBScript. If you set the return value of this function to False, the custom action operation is not completed.

Use Syntax 2 when handling the CustomAction event in Visual Basic or Visual Basic for Applications.


 CustomPropertyChange Event

CustomPropertyChange Event

Occurs when a custom property of an Outlook item is changed. The property name is passed to the procedure so that you can determine which custom property changed.

Syntax

Sub Item_CustomPropertyChange(Name As String)

Name Required. The name of the custom property that was changed.


Deactivate Event

Occurs when an explorer or inspector ceases to be the active window, either as a result of user action or through program code. This event is not available in VBScript.

Syntax

Sub object_Deactivate()

object An expression that evaluates to an Explorer or Inspector object.


 FolderAdd Event

FolderAdd Event

Occurs when a folder is added to the specified Folders collection. This event is not available in VBScript.

Syntax

Sub object_FolderAdd(Folder as MAPIFolder)

object An expression that evaluates to a Folders collection object.

Folder Required. The MAPIFolder that was added to the collection.


 FolderChange Event

FolderChange Event

Occurs when a folder in the specified Folders collection is changed. This event is not available in VBScript.

Syntax

Sub object_FolderChange(Folder as MAPIFolder)

object An expression that evaluates to a Folders collection object.

Folder Required. The MAPIFolder that was changed.


 FolderRemove Event

FolderRemove Event

Occurs when a folder is removed from the specified Folders collection. This event is not available in VBScript.

Syntax

Sub object_FolderRemove()

object An expression that evaluates to a Folders collection object.


FolderSwitch Event

Occurs when the explorer navigates to a new folder, either as a result of user action or through program code. This event is not available in VBScript.

Syntax

Sub object_FolderSwitch()

object An expression that evaluates to an Explorer object.


 Forward Event

Forward Event

Occurs when the user selects the Forward action for an Outlook item.

Syntax 1

Function Item_Forward(byVal Forward)

Syntax 2

Sub object_Forward(ByVal Forward as Object, Cancel as Boolean)

object An expression that evaluates to an object in the “Applies To” list.

Forward The new item being forwarded.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the forward operation is not completed and the new item is not displayed.

Remarks

Use Syntax 1 in VBScript. If you set the return value of this function to False, the forward action is not completed and the new item is not displayed.

Use Syntax 2 when handling the Forward event in Visual Basic or Visual Basic for Applications.


 GroupAdd Event

GroupAdd Event

Occurs when a new group has been added to the Outlook Bar. This event is not available in VBScript.

Syntax

Sub objOutlookBarStorage_GroupAdd(NewGroup as OutlookBarGroup)

object An expression that evaluates to an OutlookBarStorage object.

NewGroup Required. The OutlookBarGroup that was added.


 ItemAdd Event

ItemAdd Event

Occurs when an item is added to the specified collection. This event is not available in VBScript.

Syntax

Sub object_ItemAdd(Item as Object)

object An expression that evaluates to an Items collection object.

Item Required. The item that was added.


 ItemChange Event

ItemChange Event

Occurs when an item in the specified collection is changed. This event is not available in VBScript.

Syntax

Sub object_ItemChange(Item as Object)

object An expression that evaluates to an Items collection object.

Item Required. The item that was changed.


 ItemRemove Event

ItemRemove Event

Occurs when an item is deleted from the specified collection. This event is not available in VBScript.

Syntax

Sub object_ItemRemove()

object An expression that evaluates to an Items collection object.


ItemSend Event

Occurs whenever an item is sent, either by the user through an Inspector (before the inspector is closed, but after the user clicks the Click button) or when the Send method is used in a program. This event is not available in VBScript.

Syntax

Sub object_ItemSend(Item as Object, Cancel as Boolean)

object An expression that evaluates to an Application object.

Item Required. The item being sent.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the send action is not completed and the inspector is left open.


 NewExplorer Event

NewExplorer Event

Occurs whenever a new explorer window is opened, either as a result of user action or through program code. This event is not available in VBScript.

Syntax

Sub object_NewExplorer(Explorer as Explorer)

object An expression that evaluates to an Explorers collection object.

Explorer Required. The explorer that was opened.

Remarks

The event occurs after the new Explorer object is created but before the explorer window appears.


 NewInspector Event

NewInspector Event

Occurs whenever a new inspector window is opened, either as a result of user action or through program code. This event is not available in VBScript.

Syntax

Sub object_NewInspector(Inspector as Inspector)

object An expression that evaluates to an Inspectors collection object.

Inspector Required. The inspector that was opened.

Remarks

The event occurs after the new Inspector object is created but before the inspector window appears.


NewMail Event

Occurs when one or more new messages are received in the Inbox. This event is not available in VBScript.

Syntax

Sub object_NewMail()

object An expression that evaluates to an Application object.


OnError Event

Occurs when Microsoft Outlook encounters an error while synchronizing a user’s folders using the specified synchronization profile. This event is not available in VBScript.

Syntax

Sub object_OnError(Code as Long, Description as String)

object An expression that evaluates to a SyncObject object.

Code A unique value that identifies the error.

Description Required. A textual description of the error.


 Open Event

Open Event

Occurs when an Outlook item is being opened in an Inspector. When this event occurs, the Inspector object is initialized but not yet displayed. The Open event differs from the Read event in that Read occurs whenever the user selects the item in a view that supports in-cell editing as well as when the item is being opened in an Inspector.

Syntax 1

Function Item_Open()

Syntax 2

Sub object_Open(Cancel as Boolean)

object An expression that evaluates to an object in the “Applies To” list.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the open operation is not completed and the inspector is not displayed.

Remarks

Use Syntax 1 in VBScript. If you set the return value of this function to False, the open operation is not completed and the inspector is not displayed.

Use Syntax 2 when handling the Open event in Visual Basic or Visual Basic for Applications.


OptionsPagesAdd Event

Occurs whenever the Options dialog box (available through the Tools menu) or a folder Properties dialog box is opened. This event is not available in VBScript.

Syntax 1

Sub object_OptionsPagesAdd(Pages as PropertyPages)

Syntax 2

Sub object_OptionsPagesAdd(Pages as PropertyPages, Folder as MAPIFolder)

object An expression that evaluates to an Application or a NameSpace object.

Pages Required. The collection of property pages that have been added to the dialog box. This collection includes only custom property pages. It does not include standard Microsoft Outlook property pages.

Folder Required. The MAPIFolder object for which the Properties dialog box is being opened.

Remarks

Your program handles this event to add a custom property page. If object is an Application object, then Syntax 1 applies and the property page will be added to the Options dialog box. If object is a NameSpace object, then Syntax 2 applies and the property page will be added to Properties dialog box of the specified folder. When the event fires, the PropertyPages collection object identified by Pages contains the property pages that have been added prior to the event hander being called. To add your property page to the collection, use the Add method of the PropertyPages collection before exiting the event handler.


Progress Event

Occurs periodically while Microsoft Outlook is synchronizing a user’s folders using the specified synchronization profile. This event is not available in VBScript.

Syntax

Sub object_Progress(State as Long, Description as String, Value as Long, Max as Long)

object An expression that evaluates to a SyncObject object.

State Required. A value that identifies the current state of the synchronization process. Can be either of the following OlSyncState constants: olSyncStarted(1) or olSyncStopped(0).

Description Required. A textual description of the current state of the synchronization process.

Value Required. Specifies the current value of the synchronization process (such as the number of items synchronized).

Max Required. The maximum that Value can reach. The ratio of Value to Max represents the percent complete of the synchronization process.


 PropertyChange Event

PropertyChange Event

Occurs when a standard property (for example, Subject or To) of an Outlook item is changed. The property name is passed to the event so that you can determine which property was changed.

Syntax

Sub Item_PropertyChange(Name As String)

Name Required. The name of the property that was changed.


Quit Event

Occurs when Microsoft Outlook begins to close. This event is not available in VBScript.

Syntax

Sub object_Quit()

object An expression that evaluates to an Application object.


 Read Event

Read Event

Occurs when an existing Outlook item is opened for editing by the user. The Read event differs from the Open event in that Read occurs whenever the user selects the item in a view that supports in-cell editing as well as when the item is being opened in an Inspector.

Syntax

Sub Item_Read()


 Reminder Event

Reminder Event

Occurs immediately before a reminder is displayed.

Syntax

Sub object_Reminder(Item as Object)

object An expression that evaluates to an Application object.

Item The AppointmentItem, MailItem or TaskItem associated with the reminder. If the appointment associated with the reminder is a recurring appointment, Item is the specific occurrence of the appointment that displayed the reminder, not the master appointment.


 Reply Event

Reply Event

Occurs when the user selects the Reply action for an Outlook item.

Syntax 1

Function Item_Reply(byVal Response)

Syntax 2

Sub object_Reply(ByVal Response as Object, Cancel as Boolean)

object An expression that evaluates to an object in the “Applies To” list.

Response The new item being sent in response to the original message.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the reply operation is not completed and the new item is not displayed.

Remarks

Use Syntax 1 in VBScript. If you set the return value of this function to False, the reply action is not completed and the new item is not displayed.

Use Syntax 2 when handling the Reply event in Visual Basic or Visual Basic for Applications.


 ReplyAll Event

ReplyAll Event

Occurs when the user selects the ReplyAll action for an Outlook item.

Syntax 1

Function Item_ReplyAll(byVal Response)

Syntax 2

Sub object_ReplyAll(ByVal Response as Object, Cancel as Boolean)

object An expression that evaluates to an object in the “Applies To” list.

Response The new item being sent in response to the original message.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the reply all operation is not completed and the new item is not displayed.

Remarks

Use Syntax 1 in VBScript. If you set the return value of this function to False, the reply all action is not completed and the new item is not displayed.

Use Syntax 2 when handling the ReplyAll event in Visual Basic or Visual Basic for Applications.


SelectionChange Event

Occurs when the selection of the current view changes. Other selection changes (such as the selected folder) do not cause this event to occur. In addition, this event does not occur if the current folder is a file-system folder or if Outlook Today is displayed. This event is not available in VBScript.

Syntax

Sub object_SelectionChange()

object An expression that evaluates to an Explorer object.


 Send Event

Send Event

Occurs when the user selects the Send action for an Outlook item.

Syntax 1

Function Item_Send()

Syntax 2

Sub object_Send(Cancel as Boolean)

object An expression that evaluates to an object in the “Applies To” list.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the send operation is not completed and the inspector is left open.

Remarks

Use Syntax 1 in VBScript. If you set the return value of this function to False, the send operation is not completed and the inspector is left open.

Use Syntax 2 when handling the Send event in Visual Basic or Visual Basic for Applications.


 ShortcutAdd Event

ShortcutAdd Event

Occurs when a new shortcut is added to a Outlook Bar group. This event is not available in VBScript.

Syntax

Sub object_ShortcutAdd(NewShortcut as OutlookBarShortcut)

object An expression that evaluates to an OutlookBarShortcuts collection object.

NewShortcut Required. The shortcut that is being added.


Startup Event

Occurs when Microsoft Outlook is starting, but after all add-in programs have been loaded. This event is not available in VBScript.

Syntax

Sub object_Startup()

object An expression that evaluates to an Application object.

Remarks

An Outlook Visual Basic for Applications macro can use this event procedure to initialize itself when Outlook starts.


SyncEnd Event

Occurs immediately after Microsoft Outlook finishes synchronizing a user’s folders using the specified synchronization profile. This event is not available in VBScript.

Syntax

Sub object_SyncEnd()

object An expression that evaluates to a SyncObject object.


SyncStart Event

Occurs when Microsoft Outlook begins synchronizing a user’s folders using the specified synchronization profile. This event is not available in VBScript.

Syntax

Sub object_SyncStart()

object An expression that evaluates to a SyncObject object.


ViewSwitch Event

Occurs when the view in the explorer changes, either as a result of user action or through program code. This event is not available in VBScript.

Syntax

Sub object_ViewSwitch()

object An expression that evaluates to an Explorer object.


Write Event

Occurs when an Outlook item is saved, either explicitly (for example, using the Save or SaveAs methods) or implicitly (for example, in response to a prompt when closing the item's inspector).

Syntax 1

Function Item_Write()

Syntax 2

Sub object_Write(Cancel as Boolean)

object An expression that evaluates to an object in the “Applies To” list.

Cancel Optional. False when the event occurs. If the event procedure sets this argument to True, the save operation is not completed.

Remarks

Use Syntax 1 in VBScript. If you set the return value of this function to False, the save operation is not completed.

Use Syntax 2 when handling the Write event in Visual Basic or Visual Basic for Applications.


Activate Method

Activates an explorer or inspector window by bringing it to the foreground and setting keyboard focus.

Syntax

object.Activate

object Required. An expression that returns an Explorer or Inspector object.


ActiveExplorer Method

Returns the topmost Explorer object on the desktop. If no explorer is active, returns Nothing. Use this method to return the Explorer object that the user is most likely viewing. This method is also useful for determining when there is no active explorer, so a new one can be opened.

Syntax

objApplication.ActiveExplorer

objApplication Required. An expression that returns an Application object.


ActiveInspector Method

Returns the topmost Inspector object on the desktop. If no inspector is active, returns Nothing. Use this method to access the Inspector object that the user is most likely to be viewing.

Syntax

objApplication.ActiveInspector

objApplication Required. An expression that returns an Application object

The Inspector Object and Microsoft Word as the User’s E-mail Editor

If the user’s default e-mail editor is Microsoft Word, and if the message format of the item being edited is plain text or HTML, ActiveInspector produces an error and returns Nothing.


ActiveWindow Method

Returns an object representing the topmost Microsoft Outlook window on the desktop, either an Explorer or an Inspector object. If no Outlook explorer or inspector is open, returns Nothing.

Syntax

object.ActiveWindow

object Required. An expression that returns an Application object.


 Add Method

Add Method

Adds an object to a collection. Select one of the following collections to see a detailed description of the Add method for that collection.

Actions

AddressEntries

Attachments

Explorers

Folders

Inspectors

Items

Links

OutlookBarGroups

OutlookBarShortcuts

Pages

PropertyPages

Recipients

UserProperties


AddMembers Method

Adds new members to a distribution list.

Syntax

object.AddMembers(Recipients)

object Required. An expression that returns a DistListItem object.

Recipients Required Recipients. The members to be added to the distribution list.


AddStore Method

Adds a personal folder (.pst) file to the current profile.

Syntax

object.AddStore(Store)

object Required. An expression that returns a NameSpace object.

Store Required Variant. The path of the .pst file to be added to the profile. If the .pst file does not exist, Microsoft Outlook creates it.


Apply Method

Applies the changes that have been made in a custom property page.

Syntax

object.Apply

object Required. An expression that returns a PropertyPage object.

Remarks

Because the PropertyPage is an abstract object that is implemented in your application (rather than by Microsoft Outlook itself), the implementation of the Apply method resembles an event procedure in your program code. That is, you write the code that implements the method in much the same way you would write an event procedure. In other words, Outlook calls the Apply method to notify your program that the user has taken an action in the dialog box displaying the custom property page that requires your program to apply the property values changed by the user.


Assign Method

Assigns a task and returns a TaskItem object that represents it. This method allows a task to be assigned (delegated) to another user. You must create a task before you can assign it, and you must assign a task before you can send it. An assigned task is sent as a TaskRequestItem object.

Syntax

objTaskItem.Assign

objTaskItem Required. An expression that returns a TaskItem object.


CancelResponseState Method

Resets an unsent response to a task request back to a simple task. After you receive a task request and respond to it, but before sending the response, you can use this method to revert the task to its state before you responded.

Syntax

objTaskItem.CancelResponseState

objTaskItem Required. An expression that returns a TaskItem object.


ClearConversationIndex Method

Clears the index of the conversation thread for the mail message or post.

Syntax

object.ClearConversationIndex

object Required. An expression that returns a MailItem or PostItem object.


ClearRecurrencePattern Method

Removes the recurrence settings and restores the single-occurrence state for an appointment or task.

Syntax

object.ClearRecurrencePattern

object Required. An expression that returns an AppointmentItem or TaskItem object.


 Close Method

Close Method

For the Explorer object, the Close method closes the explorer. No information is saved.

For an Inspector or Outlook item object, the Close method closes the inspector or item and optionally saves changes to the displayed Outlook item.

Syntax 1

objExplorer.Close

objExplorer Required. An expression that returns an Explorer object.

Syntax 2

object.Close(SaveMode)

object Required. An expression that returns an Inspector or Outlook item object.

SaveMode Required Long. The close behavior. Can be one of the following OlInspectorClose constants: olDiscard(1) (discard all changes without prompting), olPromptForSave(2) (prompt to save or discard all changes), or olSave(0) (save all changes without prompting). If the item displayed within the inspector has not been changed, this argument has no effect.


 Copy Method

Copy Method

Creates and returns a copy of the object. This method is supported by all Outlook items.

Syntax

object.Copy

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


CopyTo Method

Copies the current folder in its entirety to the destination folder. Returns a MAPIFolder object that represents the new copy.

Syntax

objMAPIFolder.CopyTo(DestFldr)

objMAPIFolder Required. An expression that returns a MAPIFolder object (current folder).

DestFldr Required. A MAPIFolder object. (The destination folder for the copied folder).


 CreateItem Method

CreateItem Method

Creates a new Outlook item and returns it. The CreateItem method can only create default Outlook items. To create new items using a custom form, use the Add method on the Items collection.

Syntax

objApplication.CreateItem(ItemType)

objApplication Required. An expression that returns an Application object.

ItemType Required Long. The Outlook item Type for the new item. Can be one of the following OlItemType constants: olAppointmentItem(1), olContactItem(2), olJournalItem(4), olMailItem(0), olNoteItem(5), olPostItem(6), or olTaskItem(3).


 CreateItemFromTemplate Method

CreateItemFromTemplate Method

Creates a new Outlook item from an Outlook template (.oft) and returns the new item.

Syntax

objApplication.CreateItemFromTemplate(TemplatePath, [InFolder])

objApplication Required. An expression that returns an Application object.

TemplatePath Required String. The path and file name of the Outlook template for the new item.

InFolder Optional Variant. The folder in which the item is to be created. If this argument is omitted, the default folder for the item type will be used.


CreateObject Method

Creates an Automation object of the specified class. If the application is already running, CreateObject will create a new instance.

This method is provided so that other applications can be automated from VBScript. It should not be used to automate Outlook from VBScript.

Note The CreateObject methods commonly used in the example code within this Help file (available when you click "Example") are made available by Microsoft Visual Basic (VB) or Microsoft Visual Basic for Applications. These examples do not use the same CreateObject method that is implemented as part of Outlook's object model.

Syntax

objApplication.CreateObject(ObjectName)

objApplication Required. An expression that returns an Application object.

ObjectName Required String. The class name of the object to create. For information about valid class names, see OLE Programmatic Identifiers.


CreateRecipient Method

Creates and returns a Recipient object. This method is most commonly used to create a Recipient object for use with the GetSharedDefaultFolder method (for example, to open a delegator's folder). It can also be used to verify a given name against an address book.

Syntax

objNameSpace.CreateRecipient(RecipientName)

objNameSpace Required. An expression that returns a NameSpace object.

RecipientName Required String. The display name of the recipient.


 Delete Method

Delete Method

Deletes the object from the collection.

Syntax

object.Delete

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


 Details Method

Details Method

The Details method displays a modal dialog box that provides detailed information about an AddressEntry object. You must use error handling to handle run time errors when the user hits the cancel button in the dialog box. The Details method actually stops the code from running while the dialog box is displayed.

Note The Details method fails if the Name property is empty.

Syntax

objAddressEntry.Details([HWnd])

objAddressEntry Required. An AddressEntry object.

HWnd Optional. Long. The parent window handle for the details dialog box. A zero value (the default) specifies a modal dialog box.


 Display Method

Display Method

For a MAPIFolder object, the Display method displays a new Explorer object for the folder.

For Outlook items, the Display method displays a new Inspector object for the item.

Note The Display method is supported for explorer and inspector windows for the sake of backward compatibility. To activate an explorer and inspector window, use the Activate method.

Syntax 1

object.Display

object Required. An expression that returns a MAPIFolder object.

Syntax 2

object.Display([Modal])

object Required. An expression that returns an Outlook item object that is listed in the "Applies To" list.

Modal Optional Boolean. True to make the Inspector modal. The default value is False.


 Execute Method

Execute Method

Executes the action for the item. Returns the Outlook item created by the action.

Syntax

objAction.Execute

objAction Required. An expression that returns an Action object.


 Find Method

Find Method

Items collection object: Applies the filter to the Items collection and returns the first Item object matching the filter.

UserProperties collection object: Locates and returns a UserProperty object for the requested property name, if it exists.

Syntax 1

object.Find(Filter)

object Required. An expression that returns an Items object.

Syntax 2

object.Find(Name, Custom)

object Required. An expression that returns a UserProperties object.

Filter Required String. An expression that will evaluate to True or False.

The filter is a string expression containing one or more filter clauses joined by the logical operators And, Not, and Or.

A filter clause is a simple expression that evaluates to True or False; for example, [CompanyName] = "Microsoft".

Note that property names can be used in the expression and are identified and delimited by square brackets. Except for these bracketed property names, only literals are allowed within the expression — variables and constants are not evaluated as part of the expression. However, variables and constants can be used when constructing the expression. See Restrict Method Example for an illustration of how to use a variable when constructing the expression.

Comparison operators allowed within the filter expression include >, <, >=, <=, = and <>.

Logical operators allowed are And, Not and Or.

Name Required. String. The display name of the requested property.

Custom Optional. Boolean. True if the requested property is a user (custom) property. False if it is a system property. The default value is True.

Note If you are using user-defined fields as part of a Find or Restrict clause, the user-defined fields must exist in the folder; otherwise, the code will generate an error stating that the field is unknown. You can add a field to a folder by displaying the Field Chooser and clicking New.

Remarks

For the Items collection, Find cannot be used, and will cause an error, with the following properties:

Body

Categories

Children

Class

Companies

CompanyLastFirstNoSpace

CompanyLastFirstSpaceOnly

ContactNames

Contacts

ConversationIndex

DLName

Email1EntryID

Email2EntryID

Email3EntryID

EntryID

HTMLBody

IsOnlineMeeting

LastFirstAndSuffix

LastFirstNoSpace

 LastFirstNoSpaceCompany

LastFirstSpaceOnly

LastFirstSpaceOnlyCompany

MemberCount

NetMeetingAlias

NetMeetingAutoStart

NetMeetingOrganizerAlias

NetMeetingServer

NetMeetingType

RecurrenceState

ReplyRecipients

ReceivedByEntryID

RecevedOnBehalfOfEntryID

ResponseState

Saved

Sent

Submitted

VotingOptions


 FindNext Method

FindNext Method

After the Find method runs, this method finds and returns the next Outlook item in the collection. The search operation begins from the current position, which matches the expression previously set through Find.

Syntax

objItems.FindNext

objItems Required. An expression that returns an Items collection object.


Forward Method

Executes the Forward action for an item. Returns the resulting copy as a new object.

Syntax

object.Forward

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


ForwardAsVcal Method

Forwards the AppointmentItem as a vCal; virtual calendar item. The ForwardAsVcal method returns a MailItem with the vCal file attached.

Syntax

Set objMailItem = objAppointmentItem.ForwardAsVcal

objMailItem Required. An expression that returns a MailItem object.

objAppointmentItem Required. An expression that returns an AppointmentItem object.


ForwardAsVcard Method

Forwards the ContactItem as a vCard, the Internet standard for creating and sharing virtual business cards. The ForwardAsVcard method returns a MailItem with the vCard file attached.

Syntax

Set objMailItem = objContactItem.ForwardAsVcard

objMailItem Required. An expression that returns a MailItem object.

objContactItem Required. An expression that returns a ContactItem object.


FreeBusy Method

Returns free/busy information for the recipient. The default is to return a string representing one month of free/busy information compatible with the Microsoft Schedule+ Automation format (that is, the string contains one character for each MinPerChar minute, up to one month of information from the specified Start date).

If the optional argument CompleteFormat is omitted or False, then "free" is indicated by the character 0 and all other states by the character 1.

If CompleteFormat is True, then the same length string is returned as defined above, but the characters now correspond to the OlBusyStatus constants: olBusy (2), olFree (0), olOutOfOffice (3) or olTentative (1).

Syntax

objRecipient.FreeBusy(Start, MinPerChar, [CompleteFormat])

objRecipient Required. An expression that returns a Recipient object.

Start Required Date. The start date for the returned period of free/busy information.

MinPerChar Required Long. The number of minutes per character represented in the returned free/busy string.

CompleteFormat Optional Boolean. True if the returned string should contain not only free/busy information, but also values for each character according to the OlBusyStatus constants: olBusy (2), olFree (0), olOutOfOffice (3) and olTentative (1).


GetAssociatedAppointment Method

Returns an AppointmentItem object that represents the appointment associated with the meeting request.

Syntax

objMeetingItem.GetAssociatedAppointment(AddToCalendar)

objMeetingItem Required. An expression that returns a MeetingItem object.

AddToCalendar Required Boolean. True to add the meeting to the default Calendar folder.


GetAssociatedTask Method

Returns a TaskItem object that represents the requested task.

Note The GetAssociatedTask method will not work unless the TaskItem is processed before the method is called. There are two options for processing the task.

  • You can call the Display method before calling GetAssociatedTask.

or,

  • You can set Outlook's advanced e-mail option to process requests and responses on arrival. This option is located in the Tools menu under Options. Click E-mail Options, then click Advanced E-Mail Options, and check Process requests and responses on arrival.

Syntax

objTaskRequestItem.GetAssociatedTask(AddToTaskList)

objTaskRequestItem Required. An expression that returns a TaskRequestItem object.

AddToTaskList Required Boolean. True if the task is added to the default Tasks folder.


 GetDefaultFolder Method

GetDefaultFolder Method

Returns a MAPIFolder object that represents the default folder of the requested type for the current profile (for example, obtaining the default Calendar folder for the user who is currently logged on).

Note To return a specific nondefault folder, you use the Folders collection.

Syntax

objNameSpace.GetDefaultFolder(FolderTypeEnum)

objNameSpace Required. An expression that returns a NameSpace object.

FolderTypeEnum Required Long. The type of default folder to return. Can be one of the following OlDefaultFolders constants: olFolderCalendar(9), olFolderContacts(10), olFolderDeletedItems(3), olFolderDrafts(16), olFolderInbox(6), olFolderJournal(11), olFolderNotes(12), olFolderOutbox(4), olFolderSentMail(5), or olFolderTasks(13).


GetExplorer Method

Returns an Explorer object that represents a new, inactive Explorer initialized with the specified folder as the current folder. This method is useful for returning a new Explorer object in which to display the folder, as opposed to using the ActiveExplorer method and setting the CurrentFolder property.

The Display method can be used to activate or show the Explorer.

The GetExplorer method takes an optional argument of an OlFolderDisplayMode constant.

By default, the new Explorer will be displayed in the Normal mode (olFolderDisplayNormal) with all interface elements displayed: a message panel on the right, an Outlook bar on the left, and a folder banner across the top from which the user can pull down a folder navigation panel. The exception to this rule is when you are calling GetExplorer on delegated folders which are in No-Navigation mode by default. You can apply more restrictions to a default mode, but you cannot lessen the restrictions by changing the OlFolderDisplayMode.

The explorer can also be displayed in Folder-Only mode (olFolderDisplayFolderOnly) in which the Explorer will display with no folder list and no Outlook bar, but the drop-down list and the navigation commands will still be available.

The most restrictive mode you can use is No-Navigation mode (olFolderDisplayNoNavigation). In this mode, the Explorer will display with no folder list, no drop-down folder list, and any "Go"-type menu/command bar options should be disabled. Basically, the user should not be able to navigate to any other folder within that Explorer window. By default, a delegated (shared) folder appears in No-Navigation mode.

Syntax

objMAPIFolder.GetExplorer([DisplayMode])

objMAPIFolder Required. An expression that returns a MAPIFolder object.

DisplayMode Optional Long. The display mode of the folder. Can be one of the following OlFolderDisplayMode constants: olFolderDisplayFolderOnly(1), olFolderDisplayNoNavigation(2) or olFolderDisplayNormal(0). The default value is olFolderDisplayNormal(0).


 GetFirst Method

GetFirst Method

The GetFirst method returns the first object in the collection. Returns Nothing if no first object exists, for example, if there are no objects in the collection.

Note: To ensure correct operation of the GetFirst, GetLast, GetNext, and GetPrevious methods in a large collection, call GetFirst before calling GetNext on that collection, and call GetLast before calling GetPrevious. To ensure that you are always making the calls on the same collection, create an explicit variable that refers to that collection before entering the loop.

Syntax

Set object. objCollection.GetFirst()

Object Required. On successful return, represents the first object in the collection.

objCollection Required. The collection object.


GetFolderFromID Method

Returns a MAPIFolder object identified by the specified entry ID (if valid). This method is used for ease of transition between MAPI and OLE/Messaging applications and Outlook.

Syntax

objNameSpace .GetFolderFromID(EntryIDFolder, [StoreID])

objNameSpace Required. An expression that returns a NameSpace object.

EntryIDFolder Required String. The EntryID of the folder.

StoreID Optional String. The StoreID for the folder.


GetFreeBusy Method

The GetFreeBusy method returns a string representing the availability of the individual user for a period of 30 days from the start date, beginning at midnight of the date specified.

Note: If an address entry represents a distribution list, the status of its individual members cannot be returned to you with the GetFreeBusy method. A meeting request should be sent only to single messaging users. You can determine if a messaging user is a distribution list by determining if its DisplayType property is olDistList(1) or olPrivateDistList(5).

Syntax

strAvail = objAddressEntry.GetFreeBusy(StartDate, Interval, [CompleteFormat])

strAvail Required String. On successful return, contains a string indicating the user's availability.

objAddressEntry Required. The AddressEntry object.

StartDate Required Date. Specifies the date.

Interval Required. Long. Specifies the length of each time slot in minutes. Default is 30 minutes.

CompleteFormat Optional. Boolean.


 GetItemFromID Method

GetItemFromID Method

Returns an Outlook item identified by the specified entry ID (if valid). This method is used for ease of transition between MAPI and OLE/Messaging applications and Outlook.

Syntax

objNameSpace.GetItemFromID(EntryIDItem, [StoreID])

objNameSpace Required. An expression that returns a NameSpace object.

EntryIDItem Required String. The EntryID of the item.

StoreID Optional String. The StoreID for the folder.

Remarks

StoreId usually must be provided when retrieving an item based on its MAPI IDs.


 GetLast Method

GetLast Method

The GetLast method returns the last object in the collection. It returns Nothing if no last object exists, for example, if the collection is empty.

Note: To ensure correct operation of the GetFirst, GetLast, GetNext, and GetPrevious methods in a large collection, call GetFirst before calling GetNext on that collection, and call GetLast before calling GetPrevious. To ensure that you are always making the calls on the same collection, create an explicit variable that refers to that collection before entering the loop.

Syntax

Set object = objCollection.GetLast()

object Required. On successful return, represents the last object in the collection.

objCollection Required. The collection object.


GetMember Method

Returns a Recipient object representing a member in a distribution list.

Syntax

object.GetMember(Index)

object Required. An expression that returns a DistListItem object.

Index Required Long. The index number of the member to be retrieved.


GetNameSpace Method

Returns a NameSpace object of the specified type.

Syntax

objApplication.GetNameSpace(Type)

objApplication Required. An expression that returns an Application object.

Type Required String. The type of name space to return.

Remarks

The only supported name space type is "MAPI".


 GetNext Method

GetNext Method

The GetNext method returns the next object in the collection. It returns Nothing if no next object exists, for example, if already positioned at the end of the collection.

Note: To ensure correct operation of the GetFirst, GetLast, GetNext, and GetPrevious methods in a large collection, call GetFirst before calling GetNext on that collection, and call GetLast before calling GetPrevious. To ensure that you are always making the calls on the same collection, create an explicit variable that refers to that collection before entering the loop.

Syntax

Set object = objCollection.GetNext()

object Required. On successful return, represents the next object in the collection.

objCollection Required. The collection object.


GetOccurrence Method

The GetOccurrence method returns a specific instance of the AppointmentItem object on the specified date.

Note The GetOccurrence method generates an error if no appointment of that series exists on the specified date.

Syntax

Set objAppointmentItem = objRecurrencePattern.GetOccurrence(Date_Time)

objAppointmentItem Required. An AppointmentItem object.

objRecurrencePattern Required. A RecurrencePattern object.

Date_Time Required Date that represents local time.


GetPageInfo Method

Returns information about a custom property page.

Syntax

object.GetPageInfo(HelpFile, HelpContext)

object Required. An expression that returns a PropertyPage object.

HelpFile Required String. Specifies the Help file associated with the property page.

HelpContext Required Long. Specifies the context ID of the Help topic associated with the property page.


 GetPrevious Method

GetPrevious Method

The GetPrevious method returns the previous object in the collection. It returns Nothing if no previous object exists, for example, if already positioned at the beginning of the collection.

Note: To ensure correct operation of the GetFirst, GetLast, GetNext, and GetPrevious methods in a large collection, call GetFirst before calling GetNext on that collection, and call GetLast before calling GetPrevious. To ensure that you are always making the calls on the same collection, create an explicit variable that refers to that collection before entering the loop.

Syntax

Set object = objCollection.GetPrevious()

object Required. On successful return, represents the previous object in the collection.

objCollection Required. The collection object.


GetRecipientFromID Method

Returns a Recipient object identified by the specified entry ID (if valid). This method is used for ease of transition between MAPI and OLE/Messaging applications and Outlook.

Syntax

objNameSpace.GetRecipientFromID(EntryID)

objNameSpace Required. An expression that returns a NameSpace object.

EntryID Required String. The EntryID of the recipient.


GetRecurrencePattern Method

Returns a RecurrencePattern object that represents the recurrence attributes of an appointment or task. If there is no existing recurrence pattern, a new, empty RecurrencePattern object is returned.

Syntax

object.GetRecurrencePattern

object Required. An expression that returns an AppointmentItem or TaskItem object.


GetSharedDefaultFolder Method

Returns a MAPIFolder object that represents the specified default folder for the specified user. This method is most useful in the delegation scenario, where one user has delegated access to another user for one or more of their default folders (for example, their shared Calendar folder).

Syntax

objNameSpace.GetSharedDefaultFolder(RecipientObject, FolderTypeEnum)

objNameSpace Required. An expression that returns a NameSpace object.

RecipientObject Required Recipient object. The owner of the folder. The Recipient object must be resolved.

FolderTypeEnum Required Long. The type of folder. Can be one of the following OlDefaultFolders constants: olFolderCalendar(9), olFolderContacts(10), olFolderDeletedItems(3), olFolderDrafts(16), olFolderInbox(6), olFolderJournal(11), olFolderNotes(12), olFolderOutbox(4), olFolderSentMail(5), or olFolderTasks(13).


 HideFormPage Method

HideFormPage Method

Hides a form page in the inspector.

Syntax

objInspector.HideFormPage(PageName)

objInspector Required. An expression that returns an Inspector object.

PageName Required String. The display name of the page to be hidden.


 IsPaneVisible Method

IsPaneVisible Method

Determines whether a specific explorer pane is visible. For example, use this method to determine if the Folder List is currently visible in the explorer. Returns True if the specified pane is displayed in the explorer.

Note You can also use the Visible property of the OutlookBarPane object to determine whether the Outlook Bar is visible.

Syntax

object.IsPaneVisible(Pane)

object Required. An expression that returns an Explorer object.

Pane Required. Must be one of the following olPanes constants: olOutlookBar(1), olFolderList(2), or olPreview(3).


IsWordMail Method

Determines whether the mail message associated with an inspector is displayed in an Outlook Inspector or in Microsoft Word. Returns True if the mail message is displayed in Microsoft Word (that is, if Word Mail is in use). The OlEditorType constant will be olEditorWord(4).

Syntax

objInspector.IsWordMail

objInspector Required. An expression that returns an Inspector object.


 Item Method

Item Method

Returns an object from a collection. The following table shows the collections supported and the object type returned.

Collection | Object Returned
Actions | Action
AddressEntries | AddressEntry
AddressLists | AddressList
Attachments | Attachment
Exceptions | Exception
Explorers | Explorer
Folders | MAPIFolder
Inspectors | Inspector
Items | Outlook item
Links | Link
OutlookBarGroups | OutlookBarGroup
OutlookBarShortcuts | OutlookBarShortcut
Pages | Page
Panes | Pane
PropertyPages | PropertyPage
Selection | Outlook item
SyncObjects | SyncObject
Recipients | Recipient
UserProperties | UserProperty

Syntax

object.Item(Index)

object Required. An expression that returns a valid collection object.

Index Required Variant. Either the index number of the object, or a value used to match the default property of an object in the collection.


 Logoff Method

Logoff Method

Logs the user off from the current MAPI session.

Syntax

objNameSpace.Logoff

objNameSpace An expression that returns a NameSpace object.


 Logon Method

Logon Method

Logs the user on to MAPI, obtaining a MAPI session.

Syntax

objNameSpace.Logon([Profile,] [Password,] ]ShowDialog,] [NewSession])

objNameSpace An expression that returns a NameSpace object.

Profile Optional String. The profile name to use for the session.

Password Optional String. The password (if any) associated with the profile.

ShowDialog Optional Boolean. True to display the MAPI logon dialog.

NewSession Optional Boolean. True to create a new session (doesn't use an existing session). Multiple sessions cannot be created in Outlook.


MarkComplete Method

Marks the task as completed. Sets PercentComplete to "100%", Complete to True, and DateCompleted to the current date.

Syntax

objTaskItem.MarkComplete

objTaskItem Required. An expression that returns a TaskItem object.


 Move Method

Move Method

Moves an Outlook item to a new folder.

Syntax

object.Move(DestFldr)

object Required. An expression that returns an Outlook item object that is listed in the "Applies To" list.

DestFldr Required. An expression that returns a MAPIFolder object. The destination folder.


MoveTo Method

Moves a folder to the specified destination folder.

Syntax

objMAPIFolder.MoveTo(DestFldr)

objMAPIFolder Required. An expression that returns a MAPIFolder object. The folder being moved.

DestFldr Required. An expression that returns a MAPIFolder object. The destination folder for the folder that is being moved.


OnStatusChange Method

Notifies Microsoft Outlook that a custom property page has changed.

Syntax

object.OnStatusChange

object Required. An expression that returns a PropertyPageSite object.


 PickFolder Method

PickFolder Method

The PickFolder method displays the Pick Folder dialog box. This is a modal dialog box which means that code execution will not continue until the user either selects a folder or cancels the dialog box. Returns a MAPIFolder object corresponding to the folder that the user selects in the dialog box. Returns Nothing when the dialog box is canceled by the user.

Syntax

objNameSpace.PickFolder

objNameSpace Required. A NameSpace object.


Post Method

Sends (posts) the PostItem object. The Post method, which is analogous to the Send method for the MailItem object, is used to save the post to the target public folder instead of mailing it.

Syntax

objPostItem.Post

objPostItem Required. An expression that returns a PostItem object.


 PrintOut Method

PrintOut Method

Prints the Outlook item using all default settings.

Note The PrintOut method is the only Outlook method that can be used for printing.

Syntax

object.PrintOut

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


 PublishForm Method

PublishForm Method

Saves the definition of the FormDescription object in the specified form registry (library).

Forms are registered as one of three classes: Folder, Organization, or Personal. The Folder form registry holds a set of forms that are only accessible from that specific folder, whether public or private. The Organization form registry holds forms that are shared across an entire enterprise and thus are accessible to everyone. The Personal form registry holds forms that are accessible only to the current store user.

Note The Name property must be set before you can use the PublishForm method.

Syntax

objFormDescription.PublishForm(Registry, [Folder])

objFormDescription Required. An expression that returns a FormDescription object.

Registry Required Long. The form class. Can be one of the following OlFormRegistry constants: olDefaultRegistry(0), olFolderRegistry(3), olOrganizationRegistry(4), or olPersonalRegistry(2). Use olDefaultRegistry to handle items without regard to their form class.

Folder Optional except with olFolderRegistry. Expression that returns a MAPIFolder object. Used only with Folder form registry. The folder object from which the forms must be accessed.


 Quit Method

Quit Method

Closes all currently open windows. The associated Outlook session is closed completely: the user is logged out of the messaging system and any changes to items not already saved are discarded.

Syntax

objApplication.Quit

objApplication Required. An expression that returns an Application object.


 Remove Method

Remove Method

Removes the object from the collection.

Syntax

object.Remove(Index)

object Required. An expression that returns a collection object in the Applies To list.

Index Required Long. The index of the object within the collection.


RemoveMembers Method

Removes members from a distribution list.

Syntax

object.RemoveMembers(Recipients)

object Required. An expression that returns a DistListItem object.

Recipients Required Recipients. The members to be removed from the distribution list.


Reply Method

Creates a reply, pre-addressed to the original sender, from the original message. Returns the reply as a MailItem object.

Syntax

object.Reply

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


ReplyAll Method

Creates a reply to all original recipients from the original message. Returns the reply as a MailItem object.

Syntax

object.ReplyAll

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


ResetColumns Method

The ResetColumns method clears the properties that have been cached with the SetColumns method. All properties are accessible after calling the ResetColumns method. SetColumns should be reused to store new properties again. ResetColumns does nothing if SetColumns has not been called first.

Syntax

objItems.ResetColumns()

objItems Required. An Items collection object.


Resolve Method

Attempts to resolve a Recipient object against the AddressBook. Returns True if the object was resolved, False if it was not.

Syntax

objRecipient.Resolve

objRecipient Required. An expression that returns a Recipient object.


ResolveAll Method

Attempts to resolve all the Recipient objects in the Recipients collection against the AddressBook. Returns True if all of the objects were resolved, False if one or more were not.

Syntax

objRecipient.ResolveAll

objRecipient Required. An expression that returns a Recipient object.


Respond Method

Responds to a meeting request for the AppointmentItem object or a task request for the TaskItem object.

Syntax

object.Respond(IResponse, [fNoUI], [fAdditionalTextDialog])

object Required. An expression that returns an AppointmentItem or TaskItem object.

IResponse Required Long. The response to the request.

For a TaskItem, can be one of the following OlTaskResponse constants: olTaskAccept (2), olTaskAssign(1), olTaskDecline(3), or olTaskSimple(0).

For an AppointmentItem, can be one of the following OlMeetingResponse constants: olMeetingAccepted(3), olMeetingDeclined(4), or olMeetingTentative(2).

fNoUI Optional for AppointmentItem, required for TaskItem. Boolean. True to not display a dialog box; the response is sent automatically. False to display the dialog box for responding.

fAdditionalTextDialog Optional for AppointmentItem, required for TaskItem. Boolean. False to not prompt the user for input; the response is displayed in the inspector for editing. True to prompt the user to either send or send with comments. This argument is valid only if fNoUI is False.

Note The possible values for the optional parameters, fNoUI and fAdditionalTextDialog and the subsequent results are as follows:

fNoUI, fAdditionalTextDialog | Result
True, True | For AppointmentItem and TaskItem: Response item is returned with no user interface. To send the response, you must call the Send method.
True, False | For AppointmentItem and TaskItem: Same result as with True, True.
False, True | For AppointmentItem: Prompts user to Send or Edit before sending response. For TaskItem: If Display method has been called, the user prompt appears. Otherwise, the item is sent without prompting and resulting item is nothing.
False, False | For AppointmentItem: New response item appears in the user interface, but no prompt. For TaskItem: Does nothing.


 Restrict Method

Restrict Method

Applies a filter to the Items collection, returning a new collection containing all items from the original which match the filter. This method is an alternative to using the Find method or FindNext method to iterate over specific items within a collection. Find or FindNext is faster than filtering if there are a small number of items. Restrict is useful where performance is not a concern.

Note If you are using user-defined fields as part of a Find or Restrict clause, the user-defined fields must exist in the folder otherwise the code will generate an error stating that the field is unknown. You can add a field to a folder by displaying the Field Chooser and clicking New.

Syntax

objItems.Restrict(Filter)

objItems Required. An expression that returns an Items collection object.

Filter Required String. A filter string expression to be applied. For details, see the Find method.

Remarks

This method cannot be used, and will cause an error, with the following properties:

Body

Categories

Children

Class

Companies

CompanyLastFirstNoSpace

CompanyLastFirstSpaceOnly

ContactNames

Contacts

ConversationIndex

DLName

Email1EntryID

Email2EntryID

Email3EntryID

EntryID

HTMLBody

IsOnlineMeeting

LastFirstAndSuffix

LastFirstNoSpace

 LastFirstNoSpaceCompany

LastFirstSpaceOnly

LastFirstSpaceOnlyCompany

MemberCount

NetMeetingAlias

NetMeetingAutoStart

NetMeetingOrganizerAlias

NetMeetingServer

NetMeetingType

RecurrenceState

ReplyRecipients

ReceivedByEntryID

RecevedOnBehalfOfEntryID

ResponseState

Saved

Sent

Submitted

VotingOptions


 Save Method

Save Method

Saves the Outlook item to the current folder or, if this is a new item, to the Outlook default folder for the item type.

Syntax

object.Save

object Required. An expression that returns an Outlook item object that is listed in the "Applies To" list.


 SaveAs Method

SaveAs Method

Saves the Outlook item to the specified path and in the format of the specified file type. If the file type is not specified, the MSG format is used.

Syntax

object.SaveAs(Path, [Type])

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.

Path Required String. The path on which to save the item.

Type Optional Variant. The file type to save. Can be one of the following OlSaveAsType constants: olDoc(4), olHTML(5), olMSG(3), olRTF(1), olTemplate(2), olTXT(0), olVCal(7), or olVCard(6).


SaveAsFile Method

Saves the attachment to the specified path.

Syntax

objAttachment.SaveAsFile(Path)

objAttachment Required. An expression that returns an Attachment object.

Path Required String. The location at which to save the attachment.


Send Method

Sends the appointment, meeting item, mail message, or task.

Syntax

object.Send

object Required. An expression that returns an AppointmentItem, MeetingItem, MailItem, or TaskItem object.


 SetColumns Method

SetColumns Method

The SetColumns method allows the user to cache certain properties for extremely fast access to those particular properties of the item. The SetColumns method is useful for iterating through the Items collection. If you don't use this method, Outlook must open each item to access the property. With the SetColumns method, Outlook only checks the properties that you have cached. Properties which are not cached are returned empty.

Syntax

objItems.SetColumns(Columns)

objItems Required. An Items collection object.

Columns Required. A String containing the names of the properties to be cached, separated by commas.

Remarks

For the Items collection, SetColumns cannot be used, and will cause an error, with any property that returns an object, and it cannot be used with the following properties:

Body

Categories

Children

Class

Companies

Contacts

DLName

EntryID

HTMLBody

MemberCount

RecurrenceState

ReplyRecipients

ResponseState

Saved

Sent

Submitted

VotingOptions


 SetCurrentFormPage Method

SetCurrentFormPage Method

Displays the specified form page in the inspector.

Syntax

objInspector.SetCurrentFormPage(PageName)

objInspector Required. An expression that returns an Inspector object.

PageName Required String. The display name of the form page.


 ShowFormPage Method

ShowFormPage Method

Shows a form page in the inspector.

Syntax

objInspector.ShowFormPage(PageName)

objInspector Required. An expression that returns an Inspector object.

PageName Required String. The display name of the page to be shown.


 ShowPane Method

ShowPane Method

Displays or hides a specific pane in the explorer.

Note You can also use the Visible property of the OutlookBarPane object to display or hide the Outlook Bar.

Syntax

object.ShowPane(Pane, Visible)

object Required. An expression that returns an Explorer object.

Pane Required. Must be one of the following olPanes constants: olOutlookBar(1), olFolderList(2), or olPreview(3).

Visible Required. True to make the pane visible, False to hide the pane.


SkipRecurrence Method

Clears the current instance of a recurring task and sets the recurrence to the next instance of that task.

Syntax

objTaskItem.SkipRecurrence

objTaskItem Required. An expression that returns a TaskItem object.


 Sort Method

Sort Method

Sorts the collection of items by the specified property. The index for the collection is reset to 1 upon completion of this method.

For Items:

Syntax 1

objItems.Sort(Property, [Descending])

objItems Required. An expression that returns an Items collection object.

Property Required String. The name of the property by which to sort, which may be enclosed in brackets (for example, "[CompanyName]"). May not be a user-defined field, and may not be a multi-valued property, such as a category.

Descending Optional Boolean. True to sort in descending order. The default value is False (ascending).

For the AddressEntries collection:

Syntax 2

obAddressEntries.Sort([Property], [Descending])

objAddressEntries Required. An expression that returns an AddressEntries collection object.

Property Optional String. The name of the property by which to sort, which may be enclosed in brackets (for example, "[Name]").

Descending Optional Long. Can be one of the OlSortOrder constants:

olAscending(1), olDescending(2), or olSortNone(0).

Remarks

For the Items collection, Sort cannot be used, and will cause an error, with the following properties:

Categories

Children

Class

Companies

CompanyLastFirstNoSpace

CompanyLastFirstSpaceOnly

Contacts

DLName

IsOnlineMeeting

LastFirstAndSuffix

LastFirstNoSpace

 LastFirstNoSpaceCompany

LastFirstSpaceOnly

LastFirstSpaceOnlyCompany

MemberCount

NetMeetingAlias

NetMeetingAutoStart

NetMeetingOrganizerAlias

NetMeetingServer

NetMeetingType

RecurrenceState

ResponseState

Saved

Sort only affects the order of items in a collection. It does not affect the order of items in an explorer view.


Start Method

Begins synchronizing a user’s folders using the specified synchronization profile.

Syntax

object.Start

object Required. An expression that returns a SyncObject object.


StartTimer Method

Starts the timer on the journal entry. This method allows programmatic control of the timer function. The Duration, End and Start properties are automatically updated when the timer is stopped.

Syntax

objJournalItem.StartTimer

objJournalItem Required. An expression that returns a JournalItem object.


StatusReport Method

Sends a status report to all CC recipients (recipients returned by the StatusUpdateRecipients property) with the current status for the task.

Syntax

objTaskItem.StatusReport

objTaskItem Required. An expression that returns a TaskItem object.


Stop Method

Immediately ends synchronizing a user’s folders using the specified synchronization profile. This method does not undo any synchronization that has already occurred.

Syntax

object.End

object Required. An expression that returns a SyncObject object.


StopTimer Method

Stops the timer on the journal entry. This method allows programmatic control of the timer function. The Duration, End and Start properties are automatically updated when the timer is stopped.

Syntax

objJournalItem.StopTimer

objJournalItem Required. An expression that returns a JournalItem object.


Update Method

The Update method posts a change to the AddressEntry object in the messaging system.

New entries or changes to existing entries are not persisted in the collection until the Update method has been called with its makePermanent parameter set to True.

To flush the cache and then reload the values from the address book, call Update with the makePermanent parameter set to False and the refreshObject parameter set to True.

Syntax

objAddressEntry.Update([makePermanent], [refreshObject])

objAddressEntry Required. The AddressEntry object.

makePermanent Optional. Boolean. A value of True indicates that the property cache is flushed and all changes are committed in the underlying address book. A value of False indicates that the property cache is flushed but not committed to persistent storage. The default value is True.

refreshObject Optional. Boolean. A value of True indicates that the property cache is reloaded from the values in the underlying address book. A value of False indicates that the property cache is not reloaded. The default value is False.


 Action Object

Action Object

Actions collection (Action object)

Represents a specialized action (for example, the voting options response) that can be executed on an item. The Action object is a member of the Actions collection.

Using the Action Object

Use Actions(index), where index is the name of an available action, to return a single Action object.

The following Visual Basic for Applications example uses the "Reply" action of a particular item to send a reply.

Set myOlApp = CreateObject("Outlook.Application")
myItem = CreateItem(olMailItem)
Set myReply = myItem.Actions("Reply").Execute

The following Visual Basic for Applications example does the same thing, using a different reply style for the reply.

Set myOlApp = CreateObject("Outlook.Application")
myItem = CreateItem(olMailItem)
myItem.Actions("Reply").ReplyStyle = _
    olIncludeOriginalText
Set myReply = myItem.Actions("Reply").Execute


 Actions Collection Object

Actions Collection Object

Actions collection (Action object)

A collection of Action objects that represent all the specialized actions that can be executed on an Outlook item.

Using the Actions Collection

Use the Actions property to return the Actions collection for any Outlook item object.

Use Actions(index), where index is the name of an available action, to return a single Action object.

The following Visual Basic for Applications example uses the "Reply" action of a particular item to send a reply.

Set myOlApp = CreateObject("Outlook.Application")
myItem = CreateItem(olMailItem)
Set myReply = myItem.Actions("Reply").Execute


 AddressEntries Collection Object

AddressEntries Collection Object

AddressLists collection (AddressList object)
AddressEntries collection (AddressEntry object)

The AddressEntries collection object is a collection of addresses in an AddressList object. The collection may contain zero or more AddressEntry objects and provides access to the entries in a transport provider's address book container.

Using the AddressEntries Collection Object

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myAddressList = myNameSpace.AddressLists("Personal Address Book
Set myAddressEntries = myAddressList.AddressEntries

You can also index directly into the AddressEntries collection, returning an AddressEntry object.

Set myAddressEntry = myAddressList.AddressEntries(index)


AddressEntry Object

AddressLists collection (AddressList object)
AddressEntries collection (AddressEntry object)

The AddressEntry object is an address in an AddressEntries collection object. Each AddressEntry object in the collection holds information that represents a person or process to which the messaging system can deliver messages.

Using the AddressEntry Object

Set myAddressEntry = myRecipient.AddressEntry

Use AddressEntries(index), where index is the index number of an address entry or a value used to match the default property of an address entry, to return a single AddressEntry object.

Set myAddressEntry = myAddressEntries.Item(index)


 AddressList Object

AddressList Object

AddressLists collection (AddressList object)
AddressEntries collection (AddressEntry object)

The AddressList object is an address book that contains a set of AddressEntry objects. For instance, the Personal Address List is an AddressList object.

The AddressList object supplies a list of address entries to which a messaging system can deliver messages. An AddressList object represents one address book container available under the transport provider's address book hierarchy for the current session. The entire hierarchy is available through the parent AddressLists collection.

Using the AddressList Object

Set myAddressList = Application.Session.AddressLists("Personal Address Book")


 AddressLists Collection Object

AddressLists Collection Object

AddressLists collection (AddressList object)
AddressEntries collection (AddressEntry object)

The AddressLists collection contains a set of AddressList objects. The AddressLists collection provides access to the root of the transport provider's address book hierarchy for the current session.

Using the AddressLists Collection Object

Set myAddressLists = myNameSpace.AddressLists


 Application Object

Application Object

Represents the entire Microsoft Outlook application. This is the only object in the hierarchy that can be returned by using the CreateObject method or the intrinsic Visual Basic GetObject function.

The Outlook Application object has several purposes:

  • As the root object, it allows access to other objects in the Outlook hierarchy.

  • It allows direct access to a new item created by using CreateItem, without having to traverse the object hierarchy.

  • It allows access to the active interface objects (the explorer and the inspector)

Using the Application Object

When you use Automation to control Microsoft Outlook from another application, you use the CreateObject method to create an Outlook Application object.

The following Visual Basic for Application example starts Microsoft Outlook (if it's not already running) and opens the default Inbox folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder= _
    myNameSpace.GetDefaultFolder(olFolderInbox)
myFolder.Display

The following Visual Basic for Applications example uses the Application object to create and open a new contact.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)
myItem.Display


AppointmentItem Object

Represents an appointment in the Calendar folder. An AppointmentItem object can represent a meeting, a one-time appointment, or a recurring appointment or meeting.

Using the AppointmentItem Object

Use the CreateItem method to create an AppointmentItem object that represents a new appointment.

The following Visual Basic for Applications example returns a new appointment.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olAppointmentItem)

Use Items(index), where index is the index number of an appointment or a value used to match the default property of an appointment, to return a single AppointmentItem object from a Calendar folder.

You can also return an AppointmentItem object from a MeetingItem object by using the GetAssociatedAppointment method.


 Attachment Object

Attachment Object

Attachments collection (Attachment object)

Represents a document or link to a document contained in an Outlook item.

Using the Attachment Object

Use Attachments(index), where index is the index number, to return a single Attachment object.

Use the Add method to add an attachment to an item.

The following Visual Basic for Applications example creates a new mail message, attaches a Q496.xls as an attachment (not a link), and gives the attachment a descriptive caption.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myAttachments = myItem.Attachments
myAttachments.Add "C:\My Documents\Q496.xls", _
    olByValue, 1, "4th Quarter 1996 Results Chart"


 Attachments Collection Object

Attachments Collection Object

Attachments collection (Attachment object)

A collection of Attachment objects that represent the attachments in an Outlook item.

Using the Attachments Collection

Use the Attachments property to return the Attachments collection for any Outlook item (except notes).

Use the Add method to add an attachment to an item.

To ensure consistent results, always save an item before adding or removing objects in the Attachments collection of the item.

The following Visual Basic for Applications example creates a new mail message, attaches a Q496.xls as an attachment (not a link), and gives the attachment a descriptive caption.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.Save
Set myAttachments = myItem.Attachments
myAttachments.Add "C:\My Documents\Q496.xls", _
    olByValue, 1, "4th Quarter 1996 Results Chart"

Use Attachments(index), where index is the index number, to return a single Attachment object.


ContactItem Object

Represents a contact in a contacts folder. A contact can represent any person with whom you have any personal or professional contact.

Using the ContactItem Object

Use the CreateItem method to create a ContactItem object that represents a new contact.

The following Visual Basic for Applications example returns a new contact.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)

The following VBScript example returns a new contact.

Set myItem = Application.CreateItem(olContactItem)

Use Items(index), where index is the index number of a contact or a value used to match the default property of a contact, to return a single ContactItem object from a Contacts folder.


DistListItem Object

Represents a distribution list in a contacts folder. A distribution list can contain multiple recipients and is used to send messages to everyone in the list.

Using the DistListItem Object

Use the CreateItem method to create a DistListItem object that represents a new distribution list. The following Microsoft Visual Basic for Applications example creates and displays a new distribution list.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olDistributionListItem)
myItem.Display

Use Items(index), where index is the index number of an item in a contacts folder or a value used to match the default property of an item in the folder, to return a single DistListItem object from a contacts folder (that is, a folder whose default item type is olContactItem, the value of which is 2). The following Visual Basic for Applications example sets the current folder as the contacts folder and displays an existing distribution list named Project Team in the folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderContacts)
myFolder.Display
Set myItem = myFolder.Items("Project Team")
myItem.Display


 DocumentItem Object

DocumentItem Object

A DocumentItem object is any document other than an Outlook item as an item in an Outlook folder. In common usage, this will be an Office document but may be any type of document or executable file.


Exception Object

Exceptions collection (Exception object)

The Exception object holds information about one instance of an AppointmentItem object which is an exception to a recurring series. Unlike most of the other Outlook objects, the Exception object is a read-only object. This means that you cannot create an Exception object but, rather, the object is created when a property of an AppointmentItem is altered. For example, if you change the Start property of one AppointmentItem, you have created an Exception in AppointmentItem.RecurrencePattern.Exceptions.

Note The Exceptions collection is on the RecurrencePattern, not the AppointmentItem itself.

The Exception object can be accessed from the RecurrencePattern object through the Exceptions collection.

Using the Exception Object

In Visual Basic for Applications:

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderCalendar)
Set myItems = myFolder.Items
Set myApptItem = myItems("Daily Meeting")
Set myRecurrencePattern = myApptItem.GetRecurrencePattern
Set myException = myRecurrencePattern.Exceptions.Item(1)

In VBScript:

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(9)
Set myItems = myFolder.Items
Set myApptItem = myItems("Daily Meeting")
Set myRecurrencePattern = myApptItem.GetRecurrencePattern
Set myException = myRecurrencePattern.Exceptions.Item(1)


 Exceptions Collection Object

Exceptions Collection Object

Exceptions collection (Exception object)

The Exceptions collection object is a group of Exception objects. If you have a recurring AppointmentItem, the RecurrencePattern object defines the recurrence of these appointments. The Exceptions collection contains the group of Exception objects that define the exceptions to that series of appointments.

Exception objects are added to the Exceptions collection whenever a property in the corresponding AppointmentItem object is altered.

Using the Exceptions Collection Object

Set myExceptions = myRecurrencePattern.Exceptions


Explorer Object

Explorers collection (Explorer object)

Represents the window in which the contents of a folder are displayed.

Using the Explorer Object

Use the Item method of the Explorers collection to return the object representing a specific explorer.

Use the ActiveExplorer method to return the object representing the currently active explorer (if there is one).

Use the GetExplorer method to return the Explorer object associated with a folder.

Use the Display method of a MapiFolder object to display a folder in its associated explorer.


 Explorers Collection Object

Explorers Collection Object

Explorers collection (Explorer object)

The Explorers collection contains a set of Explorer objects representing all explorers. An explorer need not be visible to be included in the collection.

Using the Explorers Collection Object

Use the Explorers property to return the Explorers collection from the Application object. The following example shows how to retrieve the Explorers collection in Microsoft Visual Basic or Microsoft Visual Basic for Applications.

Dim myOlApp as New Outlook.Application
Set myExplorers = myOLApp.Explorers

The following example shows how to retrieve the Explorers collection in VBScript.

Set myExplorers= Application.Explorers


 Folders Collection Object

Folders Collection Object

Folders collection (MAPIFolder object)

A collection of MAPIFolder objects that represent all the available Outlook folders in a specific subset at one level of the folder tree.

Using the Folders Collection

Use the Folders property to return the Folders collection from a NameSpace object or another MAPIFolder object.

Use Folders(index), where index is the name or index number, to return a single MAPIFolder object. Folder names are case-sensitive.

The following Visual Basic for Applications example returns the folder named "Old Contacts" from myFolder

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(olFolderContacts)
Set myNewFolder = myFolder.Folders("Old Contacts")

The following Visual Basic for Applications example returns the first folder in myFolder.

Set myNewFolder = myFolder.Folders(1)


 FormDescription Object

FormDescription Object

Contains the general properties of an Outlook form. The properties of an Outlook form are displayed on the Properties page of a form in design mode.

To see the Properties page in design mode, open the Outlook item, select Forms on the Tools menu, click Design This Form, and then click the Properties tab in the item's window.

Using the FormDescription Object

Use the FormDescription property to return the FormDescription object associated with an Outlook item.


 Inspector Object

Inspector Object

Inspectors collection (Inspector object)

Represents the window in which an Outlook item is displayed.

Using the Inspector Object

Use the ActiveInspector method to return the object representing the currently active inspector (if there is one).

Use the GetInspector property to return the Inspector object associated with an item.

Use the Display method to display an item in its associated inspector.

The Inspector Object and Microsoft Word as the User’s E-mail Editor

If the user’s default e-mail editor is Microsoft Word, and if the message format of the item being edited is plain text or HTML, then no Inspector object is associated with the item.


 Inspectors Collection Object

Inspectors Collection Object

Inspectors collection (Inspector object)

The Inspectors collection contains a set of Inspector objects representing all inspectors. An inspector need not be visible to be included in the collection.

Using the Inspectors Collection Object

Use the Inspectors property to return the Inspectors collection from the Application object. The following example shows how to retrieve the Inspectors collection in Microsoft Visual Basic or Microsoft Visual Basic for Applications.

Dim myOlApp as New Outlook.Application
Set myInspectors = myOLApp.Inspectors

The following example shows how to retrieve the Inspectors collection in VBScript.

Set myInspectors= Application.Inspectors


 Items Collection Object

Items Collection Object

Folders collection (MAPIFolder object)
Items collection (Item object)

A collection of Outlook item objects in a folder.

Using the Items Collection

Use the Items property to return the Items collection of a MAPIFolder object.

Use Items(index), where index is the name or index number, to return a single Outlook item.

The following Visual Basic for Applications example returns the first item with the subject "Need your advice" in myFolder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItem = myFolder.Items("Need your advice")

The following Visual Basic for Applications example returns the first item in myFolder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItem = myFolder.Items(1)

The following VBScript example returns the first item in myFolder.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(6)
Set myItem = myFolder.Items(1)


JournalItem Object

Represents a journal entry in a Journal folder. A journal entry represents a record of all Outlook-moderated transactions for any given period.

Using the JournalItem Object

Use the CreateItem method to create a JournalItem object that represents a new journal entry. The following example returns a new journal entry.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olJournalItem)

Use Items(index), where index is the index number of a journal entry or a value used to match the default property of a journal entry, to return a single JournalItem object from a Journal folder.


 Link Object

Link Object

Links colleciton (Link object)

Represents an item that is linked to another Microsoft Outlook item. Each item has a Links collection associated with it that represents all the items that have been linked to the item.

Note For Outlook 2000, only contacts can be linked to other items.

Using the Link Object

Use the Item method to retrieve the Link object from a Links collection object. Because the Name property is the default property of the Link object, you can identify the linked item by name.

Set myLink = myLinks.Item("Microsoft Corporation")


 Links Collection Object

Links Collection Object

Links colleciton (Link object)

The Links collection contains a set of Link objects representing all items linked to a particular Microsoft Outlook item.

Using the Links Collection Object

Use the Links property to return the Links collection object from the item object.

Set myLinks = myItem.Links


MailItem Object

Represents a mail message in an Inbox (mail) folder.

Using the MailItem Object

Use the CreateItem method to create a MailItem object that represents a new mail message. The following example creates and displays a new mail message.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.Display

Use Items(index), where index is the index number of a mail message or a value used to match the default property of a message, to return a single MailItem object from an Inbox folder. The following example sets the current folder as the Inbox and displays the second mail message in the folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder =_ myNamespace.GetDefaultFolder(olFolderInbox)
myFolder.Display
Set myItem = myFolder.Items(2)
myItem.Display


 MAPIFolder Object

MAPIFolder Object

Folders collection (MAPIFolder object)

Represents an Outlook folder. A MAPIFolder object can contain other MAPIFolder objects, as well as Outlook items. You can navigate nested folders by using a combination of Folders(index), which returns a folder within a name space or another folder, and the Parent property, which returns the containing object.

Using the MAPIFolder Object

Use Folders(index), where index is the name or index number, to return a single MAPIFolder object from a NameSpace object or another MAPIFolder object.

There is a set of folders within an Outlook data store that support the default functionality of Outlook. Use GetDefaultFolder(index), where index is one of the OlDefaultFolders constants to return one of the default Outlook folders in the Outlook NameSpace object. The OlDefaultFolders constants are olFolderCalendar (9), olFolderContacts (10), olFolderDeletedItems (3), olFolderDrafts (16), olFolderInbox (6), olFolderJournal (11), olFolderNotes (12), olFolderOutbox (4), olFolderSentMail (5), and olFolderTasks (13).

Use the Add method to add a folder to the Folders collection. The Add method has an optional argument that can be used to specify the type of items that can be stored in that folder. By default, folders created inside another folder inherit the type of the parent folder.

Remarks

Folders within the Outlook data store can be typed; for example, the Calendar folder will only contain AppointmentItem objects and the Contacts folder will only contain ContactItem and DistListItem objects.

Note that when items of a specific type are saved, they are saved directly into their corresponding default folder. For example, when the GetAssociatedAppointment method is applied to a MeetingItem in the Inbox folder, the appointment that is returned will be saved to the default Calendar folder.


 MeetingItem Object

MeetingItem Object

Represents an item in an Inbox (mail) folder. A MeetingItem object represents a change to the recipient's Calendar folder initiated by another party or as a result of a group action.

Using the MeetingItem Object

Unlike other Outlook objects, you cannot create this object. It is created automatically when you set the MeetingStatus property of an AppointmentItem object to olMeeting and send it to one or more users. They receive it in their inboxes as a MeetingItem.

The following example uses the CreateItem method to create an appointment. It becomes a MeetingItem with both a required and an optional attendee when it is received in the inbox of each of the recipients.

Set myItem = myOlApp.CreateItem(olAppointmentItem)
myItem.MeetingStatus = olMeeting
myItem.Subject = "Strategy Meeting"
myItem.Location = "Conference Room B"
myItem.Start = #9/24/97 1:30:00 PM#
myItem.Duration = 90
Set myRequiredAttendee = myItem.Recipients.Add("Nate _
    Sun")
myRequiredAttendee.Type = olRequired
Set myOptionalAttendee = myItem.Recipients.Add("Kevin _
    Kennedy")
myOptionalAttendee.Type = olOptional
Set myResourceAttendee = _
    myItem.Recipients.Add("Conference Room B")
myResourceAttendee.Type = olResource
myItem.Send

Use the GetAssociatedAppointment method to return the AppointmentItem object associated with a MeetingItem object, and work directly with the AppointmentItem object to respond to the request.


NameSpace Object

Represents an abstract root object for any data source. The object itself provides methods for logging in and out, accessing storage objects directly by ID, accessing certain special default folders directly, and accessing data sources owned by other users.

Using the NameSpace Object

Use GetNameSpace("MAPI") to return the Outlook NameSpace object from the Application object.

Remarks

The only data source supported is "MAPI", which allows access to all Outlook data stored in the user's mail stores.


 NoteItem Object

NoteItem Object

Links colleciton (Link object)

Represents a note in a Notes folder.

A NoteItem is not customizable. If you open a new note, you will notice that it is not possible to place it in design mode.

The Subject property of a NoteItem is read-only because it is calculated from the body text of the note. Also, the NoteItem Body can only be rich text, so the properties that correspond to HTML and Word content do not apply. Although the GetInspector property will work on notes, because notes can't be customized, some of the Inspector properties and methods will not apply to a NoteItem.

Using the NoteItem Object

Use the CreateItem method to create a NoteItem object that represents a new note. The following Microsoft Visual Basic example returns a new note.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olNoteItem)

The following example shows how to create a NoteItem object using VBScript.

Set myItem = Application.CreateItem(5)

Use Items(index), where index is the index number of a note or a value used to match the default property of a note, to return a single NoteItem object from a Notes folder.


 OutlookBarGroup Object

OutlookBarGroup Object

OutlookBarGroups collection (OutlookBarGroup object)
OutlookBarShortcuts collection (OutlookBarShortcut object)

Represents a group of shortcuts in the Outlook Bar of an explorer window.

Using the OutlookBarGroup Object

Use the Item method to retrieve the OutlookBarGroup object from an OutlookBarGroups collection object. Because the Name property is the default property of the OutlookBarGroup object, you can identify the group by name.

Set myOlBarGroup = myOutlookBarGroups.Item("Other Shortcuts")


 OutlookBarGroups Collection Object

OutlookBarGroups Collection Object

OutlookBarGroups collection (OutlookBarGroup object)
OutlookBarShortcuts collection (OutlookBarShortcut object)

The OutlookBarGroups collection contains a set of OutlookBarGroup objects representing all groups in the Outlook Bar.

Using the OutlookBarGroups Collection Object

Use the Groups property to return the OutlookBarGroups collection object from the OutlookBarStorage object.

Set myGroups = myOutlookBarStorage.Groups


 OutlookBarPane Object

OutlookBarPane Object

Panes collection (Pane object)

Represents the Outlook Bar pane in an explorer window. The Outlook Bar contains shortcuts to Microsoft Outlook and file-system folders arranged in groups.

Using the OutlookBarPane Object

Use the Item method to retrieve the OutlookBarPane object from a Panes collection object. Because the Name property is the default property of the OutlookBarPane object, you can identify the Outlook Bar pane by name.

Set myOlBarPane = myPanes.Item("OutlookBar")


 OutlookBarShortcut Object

OutlookBarShortcut Object

OutlookBarGroups collection (OutlookBarGroup object)
OutlookBarShortcuts collection (OutlookBarShortcut object)

Represents a shortcut in a group in the Outlook Bar of an explorer window.

Using the OutlookBarShortcut Object

Use the Item method to retrieve the OutlookBarShortcut object from an OutlookBarShortcuts collection object. Because the Name property is the default property of the OutlookBarShortcut object, you can identify the shortcut by name.

Set myOlBarShortcut = myOutlookBarShortcuts.Item("Calendar")


 OutlookBarShortcuts Collection Object

OutlookBarShortcuts Collection Object

OutlookBarGroups collection (OutlookBarGroup object)
OutlookBarShortcuts collection (OutlookBarShortcut object)

The OutlookBarShortcuts collection contains a set of OutlookBarShortcut objects representing all shortcuts in an Outlook Bar group.

Using the OutlookBarShortcuts Collection Object

Use the Shortcuts property to return the OutlookBarShortcuts collection object from the OutlookBarGroup object.

Set myShortcuts = myOutlookBarGroup.Shortcuts


 OutlookBarStorage Object

OutlookBarStorage Object

OutlookBarGroups collection (OutlookBarGroup object)

Represents the storage for objects in the Outlook Bar pane.

Using the OutlookBarStorage Object

Use the Contents property of an OutlookBarPane object to retrieve the OutlookBarStorage object for the pane.

Set myOLBarStorage = myPanes.Item("OutlookBar").Contents

Use the Groups property to retrieve the OutlookBarGroups collection object for the Outlook Bar.


 Pages Collection Object

Pages Collection Object

Inspectors collection (Inspector object)
Pages collection (Page object)

A collection of pages that represent the pages of an inspector. Every Inspector object has a Pages collection defined, which is empty (count 0) if the Outlook item has never been customized before.

Using the Pages Collection

Use the ModifiedFormPages property to return the Pages collection from an Inspector object. The following example returns the Pages collection for the active inspector.

Set myPages = myItem.GetInspector.ModifiedFormPages

Use the Add method to create a custom page (you can add as many as 5 customizable pages). Use the Name argument of the Add method to set the display name of the returned page. In addition to adding custom pages, you can use the Name argument to return the main page of an Inspector object for modification.

The following example returns a custom page with a default name (such as "Custom1").

Set myPage = myPages.Add

The following example returns a custom page named "My Page."

Set myPage = myPages.Add("My Page")

The following example returns the Message page if the inspector contains a mail message.

Set myPage = myPages.Add("Message")

The following example returns the General (main) page if the inspector contains a contact.

Set myPage = myPages.Add("General")

Use ModifiedFormPages(index), where index is the name or index number, to return a single page from a Pages collection.


 Panes Collection Object

Panes Collection Object

Explorers collection (Explorer object)
Panes collection (Pane object)

The Panes collection object contains the panes displayed by the specified Explorer.

Using the Panes Collection Object

Use the Panes property to return the Panes collection object from an Explorer object.

Set myPanes = myExplorer.Panes

Use the Item method to retrieve a specific pane. To retrieve the OutlookBarPane object representing the Outlook Bar, use the following:

Set myOLBarPane = myExplorer.Panes.Item("OutlookBar")

For Microsoft Outlook 2000, the Outlook Bar is the only pane that you can access through the Panes collection object.


 PostItem Object

PostItem Object

Represents a post in a public folder that others may browse. Unlike a MailItem object, a PostItem object is not sent to a recipient. You use the Post method, which is analogous to the Send method for the MailItem object, to save the PostItem to the target public folder instead of mailing it.

Using the PostItem Object

Use the CreateItem method to create a PostItem object that represents a new post. The following example returns a new post.

Set myItem = myOlApp.CreateItem(olPostItem)

Use Items(index), where index is the index number of a post or a value used to match the default property of a post, to return a single PostItem object from a public folder.


PropertyPage Object

PropertyPages collection (PropertyPage object)

Represents a custom property page in the Microsoft Outlook Options dialog box or in the folder Properties dialog box. Outlook uses this object to allow a custom property page to interact with the Apply button in the dialog box.

Using the PropertyPage Object

The PropertyPage object is an abstract object. That is, the PropertyPage object in the Microsoft Outlook 9.0 Object Library contains no implementation code. Instead, it is provided as a template to help you implement the object in Microsoft Visual Basic. This provides a predefined set of interfaces that Outlook can use to determine whether your custom property page has changed and to notify your program that the user has clicked the Apply or OK button. (If your custom property page does not rely on the Apply button, then you do not need to implement the PropertyPage object.)

A custom property page is an ActiveX control that is displayed by Outlook in the Options dialog box or in the folder Properties dialog box when the user clicks on the custom property page’s tab. To implement the PropertyPage object, the module that contains the implementation code must contain the following statement.

Implements Outlook.PropertyPage

The module must also contain procedures that implement the properties and methods of the PropertyPage object. For example, to implement the Dirty property, a procedure similar to the following appears in the module.

Private Property Get PropertyPage_Dirty() As Boolean
    PropertyPage_Dirty = gblDirty
End Property

To implement a method of the PropertyPage object, the module must contain a statement similar to the following.

Private Sub PropertyPage_Apply()
    ' Code to set properties according to the user's
    ' selections goes here.
End Sub


 PropertyPages Collection Object

PropertyPages Collection Object

PropertyPages collection (PropertyPage object)

The PropertyPages collection object contains the custom property pages that have been added to the Microsoft Outlook Options dialog box or to the folder Properties dialog box.

Using the PropertyPages Collection Object

You receive a PropertyPages collection object as a parameter of the OptionsPagesAdd event. Use the Add method to add a PropertyPage object to the collection.

Note If more than one program handles the OptionsPagesAdd event, the order in which the programs receive the event (and therefore, the order in which pages are added to the PropertyPages collection) cannot be guaranteed.


PropertyPageSite Object

Represents the container of a custom property page.

Using the PropertyPageSite Object

Use the Parent property of the ActiveX control that implements the PropertyPage object associated with the PropertyPageSite object to return the PropertyPageSite object. The declarations section of the module implementing the PropertyPage object must contain a declaration similar to the following.

Private myPropertyPageSite As Outlook.PropertyPageSite

The object is then returned from the Parent property.

Set myPropertyPageSite = Parent

Use the OnStatusChange method to notify Microsoft Outlook that the property page has changed.


Recipient Object

Recipients collection (Recipient object)

Represents a user or resource in Outlook, generally a mail message addressee.

Using the Recipient Object

Use Recipients(index), where index is the name or index number, to return a single Recipient object.

Use the Add method to create a new Recipient object and add it to the Recipients collection. The Type property of a new Recipient object is set to the default for the associated AppointmentItem, JournalItem, MailItem, MeetingItem or TaskItem object and must be reset to indicate another recipient type.

The following Visual Basic for Applications example creates a new MailItem object and adds "Jon Grande" as the recipient using the default type ("To").

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myRecipient = myItem.Recipients.Add ("Jon Grande")

The following Visual Basic for Applications example creates the same MailItem object as the preceding example, and then changes the type of the Recipient object from the default ("To") to "CC."

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myRecipient = myItem.Recipients.Add ("Jon Grande")
myRecipient.Type = olCC


 Recipients Collection Object

Recipients Collection Object

Recipients collection (Recipient object)

The Recipients collection is a standard collection of Recipient objects.

Using the Recipients Collection

Use the Recipients property to return the Recipients collection of an AppointmentItem, JournalItem, MailItem, MeetingItem or TaskItem object.

Use the Add method to create a new Recipient object and add it to the Recipients collection. The Type property of a new Recipient object is set to the default for the associated AppointmentItem, JournalItem, MailItem or TaskItem object and must be reset to indicate another recipient type.

The following example creates a new MailItem object and adds "Jon Grande" as the recipient using the default type ("To").

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myRecipient = myItem.Recipients.Add ("Jon Grande")

The following example creates the same MailItem object as the preceding example, and then changes the type of the Recipient object from the default ("To") to "CC."

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myRecipient = myItem.Recipients.Add ("Jon Grande")
myRecipient.Type = olCC

Use Recipients(index), where index is the name or index number, to return a single Recipient object.


 RecurrencePattern Object

RecurrencePattern Object

Exceptions collection (Exception object)

Represents the pattern of incidence of recurring appointments and tasks for the associated AppointmentItem and TaskItem object.

Using the RecurrencePattern Object

Use the GetRecurrencePattern method to return the RecurrencePattern object associated with an AppointmentItem or TaskItem object.

Remarks

Calling GetRecurrencePattern or ClearRecurrencePattern has the side effect of setting the IsRecurring property of the item accordingly. This property can be used as required for efficient filtering of the Items collection.

The type of recurrence pattern is indicated by the RecurrenceType property. The RecurrenceType property is the first property you should set.

The following properties are valid for all recurrence patterns: EndTime, Occurrences, StartDate, StartTime, or Type.

The following table shows the properties that are valid for the different recurrence types. The properties listed are not all required for the given type; an error occurs if the item is saved and the property is null or contains an invalid value. Monthly and yearly patterns are only valid for a single day. Weekly patterns are only valid as the Or of the DayOfWeekMask.

Value | RecurrenceType | Properties | Example
0 | olRecursDaily | Interval | Every N days
 |  | DayOfWeekMask | Every Tuesday, Wednesday, and Thursday
2 | olRecursMonthly | Interval | Every N months
 |  | DayOfMonth | The Nth day of the month
3 | olRecursMonthNth | Interval | Every N months
 |  | Instance | The Nth Tuesday
 |  | DayOfWeekMask | Every Tuesday and Wednesday
1 | olRecursWeekly | Interval | Every N weeks
 |  | DayOfWeekMask | Every Tuesday, Wednesday, and Thursday
5 | olRecursYearly | DayOfMonth | The Nth day of the month
 |  | MonthOfYear | February
6 | olRecursYearNth | Instance | The Nth Tuesday
 |  | DayOfWeekMask | Tuesday, Wednesday, Thursday
 |  | MonthOfYear | February


 RemoteItem Object

RemoteItem Object

Represents a remote item in an Inbox (mail) folder. The RemoteItem object is similar to the MailItem object, but it contains only the Subject, Received Date and Time, Sender, Size and the first 256 characters of the body of the message. It is used to give someone connecting in remote mode enough information to decide whether or not to download the corresponding mail message.

Using the RemoteItem Object

Unlike other Outlook objects, you cannot create this object. Remote items are created by Outlook automatically when you use a Remote Access System (RAS) connection. Each RemoteItem created on the local system corresponds to a pre-existing MailItem on the remote system.

Remarks

The RemoteItem object inherits a number of properties, methods, and events that, because of the nature of the object, have no function. The object browser shows these properties, methods, and events as belonging to the RemoteItem object, but attempting to use them will produce no effect.

The methods that do not work for the RemoteItem object include Close, Copy, Display, Move, and Save.

The properties that do not work for the RemoteItem object include BillingInformation, Body, Categories, Companies, and Mileage.

The events that do not work for the RemoteItem object include Open, Close, Forward, Reply, ReplyAll, and Send.


ReportItem Object

Represents a mail-delivery report in an Inbox (mail) folder. The ReportItem object is similar to a MailItem object, and it contains a report (usually the non-delivery report) or error message from the mail transport system.

Using the ReportItem Object

Unlike other Outlook objects, you cannot create this object. Report items are created automatically when any report or error in general is received from the mail transport system.


 Selection Collection Object

Selection Collection Object

Explorers collection (Explorer object)
Selection collection (Items object)

The Selection collection contains a set of Microsoft Outlook items representing the items currently selected in an explorer.

Using the Selection Collection Object

Use the Selection property to return the Selection collection object from the Explorer object.

Set mySelectedItems = myExplorer.Selection


 SyncObject Object

SyncObject Object

SyncObjects collection (SyncObject object)

Represents a synchronization profile for a user. A synchronization profile lets users configure different synchronization scenarios, selecting which folders and which filters apply.

Using the SyncObject Object

Use the Item method to retrieve the SyncObject object from a SyncObjects collection object. Because the Name property is the default property of the SyncObject object, you can identify the group by name.

Set mySyncObject = mySyncObjects.Item("Daily")

Remarks

The SyncObject object is read-only; you cannot change its properties or create new ones.


 SyncObjects Collection Object

SyncObjects Collection Object

SyncObjects collection (SyncObject object)

The SyncObjects collection object contains a set of SyncObject objects representing the synchronization profiles for a user.

Using the SyncObjects Collection Object

Use the SyncObjects property to return the SyncObjects collection object from a NameSpace object.

Set mySyncObjects = Application.GetNameSpace("MAPI").SyncObjects

Remarks

The SyncObjects collection object is read-only. You cannot add an item to the collection.


TaskItem Object

Represents a task (an assigned, delegated, or self-imposed task to be performed within a specified time frame) in a Tasks folder.

Using The TaskItem Object

Use the CreateItem method to create a TaskItem object that represents a new task.

The following Visual Basic for Applications example returns a new task.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olTaskItem)

The following sample shows how to create a task using VBScript.

Set myItem = Application.CreateItem(3)

Use Items(index), where index is the index number of a task or a value used to match the default property of a task, to return a single TaskItem object from a Tasks folder.


TaskRequestAcceptItem Object

Represents an item in an Inbox (mail) folder.

A TaskRequestAcceptItem object represents a response to a TaskRequestItem sent by the initiating user. If the delegated user accepts the task, the ResponseState property is set to olTaskAccept(2). The associated TaskItem is received by the delegator as a TaskRequestAcceptItem object.

Using the TaskRequestAcceptItem Object

Unlike other Outlook objects, you cannot create this object.

Use the GetAssociatedTask method to return the TaskItem object that is associated with this TaskRequestAcceptItem. Work directly with the TaskItem object.


TaskRequestDeclineItem Object

Represents an item in an Inbox (mail) folder.

A TaskRequestDeclineItem object represents a response to a TaskRequestItem sent by the initiating user. If the delegated user declines the task, the ResponseState property is set to olTaskDecline(3). The associated TaskItem is received by the delegator as a TaskRequestDeclineItem object.

Using the TaskRequestDeclineItem Object

Unlike other Outlook objects, you cannot create this object.

Use the GetAssociatedTask method to return the TaskItem object that is associated with this TaskRequestDeclineItem. Work directly with the TaskItem object.


 TaskRequestItem Object

TaskRequestItem Object

Represents an item in an Inbox (mail) folder. A TaskRequestItem object represents a change to the recipient's Tasks list initiated by another party or as a result of a group tasking.

Using the TaskRequestItem Object

Unlike other Outlook objects, you cannot create this object. When the sender applies the Assign and Send methods to a TaskItem object to assign (delegate) the associated task to another user, the TaskRequestItem object is created when the item is received in the recipient's inbox.

The following Visual Basic for Applications example creates a simple task, assigns it to another user, and sends it. When the task request arrives in the recipient's inbox, it is received as a TaskRequestItem.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olTaskItem)
myItem.Assign
Set myDelegate = myItem.Recipients.Add("April LaMonte")
myItem.Subject = "Prepare Agenda For Meeting"
myItem.DueDate = #9/20/97#
myItem.Send

The following example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(3)
myItem.Assign
Set myDelegate = myItem.Recipients.Add("April LaMonte")
myItem.Subject = "Prepare Agenda For Meeting"
myItem.DueDate = #9/20/97#
myItem.Send

Use the GetAssociatedTask method to return the TaskRequestItem object, and work directly with the TaskItem object to respond to the request.


TaskRequestUpdateItem Object

Represents an item in an Inbox (mail) folder.

A TaskRequestUpdateItem object represents a response to a TaskRequestItem sent by the initiating user. If the delegated user updates the task by changing properties such as the DueDate or the Status, and then sends it, the associated TaskItem is received by the delegator as a TaskRequestUpdateItem object.

Using the TaskRequestUpdateItem Object

Unlike other Outlook objects, you cannot create this object.

Use the GetAssociatedTask method to return the TaskItem object that is associated with this TaskRequestUpdateItem. Work directly with the TaskItem object


 UserProperties Collection Object

UserProperties Collection Object

UserProperties collection (UserProperty object)

A collection of UserProperty objects that represent the custom properties of an Outlook item.

Using The UserProperties Object

Use the UserProperties property to return the UserProperties collection for an Outlook item.

Use the Add method to create a new UserProperty for an item and add it to the UserProperties collection. The Add method allows you to specify a name and type for the new property. The following example adds a custom text property named "MyPropName" to myItem.

Set myProp = myItem.UserProperties.Add("MyPropName", olText)

Use UserProperties(index), where index is a name or index number, to return a single UserProperty object.

Remarks

When you create a custom property, a field is added in the folder that contains the item (using the same name as the property). That field can be used as a column in folder views.


 UserProperty Object

UserProperty Object

UserProperties collection (UserProperty object)

Represents a custom property of an Outlook item.

Using The UserProperty Object

Use UserProperties(index), where index is a name or index number, to return a single UserProperty object.

Use the Add method to create a new UserProperty for an item and add it to the UserProperties collection. The Add method allows you to specify a name and type for the new property. The following example adds a custom text property named "MyPropName" to myItem.

Set myProp = myItem.UserProperties.Add("MyPropName", olText)

Remarks

When you create a custom property, a field is added in the folder that contains the item (using the same name as the property). That field can be used as a column in folder views.


Account Property

Returns or sets the account for the contact.

Read/write String.

Syntax

objContactItem.Account

objContactItem Required. An expression that returns a ContactItem object.


 Actions Property

Actions Property

Returns an Actions collection that represents all the available actions for the Outlook item.

Read-only.

Syntax

object.Actions

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


ActualWork Property

Returns or sets the actual effort (in minutes) spent on the task.

Corresponds to the Actual work: text box on the Details page of a TaskItem.

Read/write Long.

Syntax

objTaskItem.ActualWork

objTaskItem Required. An expression that returns a TaskItem object.


Address Property

Returns or sets the e-mail address of the recipient.

Note The Address property must be set before calling the Details method.

Read/write String.

Syntax

objRecipient.Address

objRecipient Required. An expression that returns a Recipient object.


 AddressEntries Property

AddressEntries Property

Returns the AddressEntries collection for this object.

Read-only.

Syntax

objAddressList.AddressEntries

objAddressList Required. An expression that returns an AddressList object.


AddressEntry Property

Returns the AddressEntry object corresponding to the resolved recipient. Accessing the AddressEntry property forces resolution of an unresolved recipient name. If the name cannot be resolved, an error is returned. If the recipient is resolved, the Resolved property is True.

Read-only.

Syntax

objRecipient.AddressEntry

objRecipient Required. An expression that returns a Recipient object.


 AddressLists Property

AddressLists Property

Returns a collection of the address lists available for this session. The AddressLists collection represents the root of the address book hierarchy for the current session. A particular AddressList object represents one of the available address books. The type of access you obtain depends on the access permissions granted to you by each individual address book provider.

Read-only.

Syntax

objNameSpace.AddressLists

objNameSpace Required. An expression that returns a NameSpace object.


AllDayEvent Property

True if the appointment is an all-day event (as opposed to a specified time).

Corresponds to the All day event check box on the Appointment page of an AppointmentItem.

Read/write Boolean.

Syntax

objAppointmentItem.AllDayEvent

objAppointmentItem Required. An expression that returns an AppointmentItem object.


AlternateRecipientAllowed Property

True if the mail message can be forwarded.

Read/write Boolean.

Syntax

objMailItem.AlternateRecipientAllowed

objMailItem Required. An expression that returns a MailItem object.


Anniversary Property

Returns or sets the anniversary date for the contact.

Read/write Date.

Syntax

objContactItem.Anniversary

objContactItem Required. An expression that returns a ContactItem object.


AnswerWizard Property

Returns the AnswerWizard object of the application.

Read-only AnswerWizard

Syntax

object.AnswerWizard()

object Required. An expression that returns an Application object.


Application Property

Returns an Application object that represents the parent application (Microsoft Outlook) for an object.

Read-only.

Syntax

object.Application

object Required. An expression that returns an Outlook object.


AppointmentItem Property

Returns the AppointmentItem object that is the exception. Not valid for deleted appointments.

Read-only.

Syntax

objException.AppointmentItem

objException Required. An expression that returns an Exception object.


Assistant Property

Returns an Assistant object that represents the Microsoft Office Assistant.

Read-only.


AssistantName Property

Returns or sets the name of the person who is the assistant for the contact.

Corresponds to the Assistant's name: box on the Details page of a ContactItem.

Read/write String.

Syntax

objContactItem.AssistantName

objContactItem Required. An expression that returns a ContactItem object.


AssistantTelephoneNumber Property

Returns or sets the telephone number of the person who is the assistant for the contact.

Read/write String.

Syntax

objContactItem.AssistantTelephoneNumber

objContactItem Required. An expression that returns a ContactItem object.


 Attachments Property

Attachments Property

Returns an Attachments object that represents all the attachments for the item.

Read-only.

Syntax

object.Attachments

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


AutoForwarded Property

True if the mail message was automatically forwarded.

Read/write Boolean.

Syntax

objMailItem.AutoForwarded

objMailItem Required. An expression that returns a MailItem object.


AutoResponse Property

Returns or sets the text of an automatic response for a Recipient.

Read/write String.

Syntax

objRecipient.AutoResponse

objRecipient Required. An expression that returns a Recipient object.


BCC Property

Returns the display list of blind carbon copy (BCC) names for a MailItem. This property contains the display names only. The Recipients collection should be used to modify the BCC recipients.

Read/write String.

Syntax

objMailItem.BCC

objMailItem Required. An expression that returns a MailItem object.


 BillingInformation Property

BillingInformation Property

Returns or sets the billing information associated with the Outlook item. This is a free-form text field.

Read/write String.

Syntax

object.BillingInformation

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


Birthday Property

Returns or sets the birthday for the contact.

Corresponds to the Birthday: field on the Details page of a ContactItem.

Read/write Date.

Syntax

objContactItem.Birthday

objContactItem Required. An expression that returns a ContactItem object.


 Body Property

Body Property

Returns or sets the clear-text body of the Outlook item.

Note The EditorType property is not affected when you merely access the Body property of the item (as in MsgBox myItem.Body), but when you reset the Body property (as in myItem.Body = "This is a new body"), the EditorType reverts back to the user's default editor.

Read/write String.

Syntax

object.Body

object Required. An expression that returns an Outlook item object that is listed in the "Applies To" list.


Business2TelephoneNumber Property

Returns or sets the second business telephone number for the contact.

Read/write String.

Syntax

objContactItem.Business2TelephoneNumber

objContactItem Required. An expression that returns a ContactItem object.


BusinessAddress Property

Returns or sets the whole, unparsed business address for the contact.

Read/write String.

Syntax

objContactItem.BusinessAddress

objContactItem Required. An expression that returns a ContactItem object.


BusinessAddressCity Property

Returns or sets the city name portion of the business address for the contact.

Read/write String.

Syntax

objContactItem.BusinessAddressCity

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the BusinessAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to the BusinessAddress property.


BusinessAddressCountry Property

Returns or sets the country code portion of the business address for the contact.

Read/write String.

Syntax

objContactItem.BusinessAddressCountry

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the BusinessAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to the BusinessAddress property.


BusinessAddressPostalCode Property

Returns or sets the postal code (zip code) portion of the business address for the contact.

Read/write String.

Syntax

objContactItem.BusinessAddressPostalCode

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the BusinessAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to the BusinessAddress property.


BusinessAddressPostOfficeBox Property

Returns or sets the post office box number portion of the business address for the contact.

Read/write String.

Syntax

objContactItem.BusinessAddressPostOfficeBox

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the BusinessAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to the BusinessAddress property.


BusinessAddressState Property

Returns or sets the state code portion of the business address for the contact.

Read/write String.

Syntax

objContactItem.BusinessAddressState

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the BusinessAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to the BusinessAddress property.


BusinessAddressStreet Property

Returns or sets the street address portion of the business address for the contact.

Read/write String.

Syntax

objContactItem.BusinessAddressStreet

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the BusinessAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to the BusinessAddress property.


BusinessFaxNumber Property

Returns or sets the business fax number for the contact.

Read/write String.

Syntax

objContactItem.BusinessFaxNumber

objContactItem Required. An expression that returns a ContactItem object.


BusinessHomePage Property

Returns or sets the URL of the business Web page for the contact.

Read/write String.

Syntax

objContactItem.BusinessHomePage

objContactItem Required. An expression that returns a ContactItem object.


BusinessTelephoneNumber Property

Returns or sets the first business telephone number for the contact.

Read/write String.

Syntax

objContactItem.BusinessTelephoneNumber

objContactItem Required. An expression that returns a ContactItem object.


BusyStatus Property

Returns or sets the busy status of the user for the appointment. Can be one of the following OlBusyStatus constants: olBusy(2), olFree(0), olOutOfOffice(3), or olTentative(1).

Read/write Long.

Syntax

objAppointmentItem.BusyStatus

objAppointmentItem Required. An expression that returns an AppointmentItem object.


CallbackTelephoneNumber Property

Returns or sets the callback telephone number for the contact.

Read/write String.

Syntax

objContactItem.CallbackTelephoneNumber

objContactItem Required. An expression that returns a ContactItem object.


Caption Property

Returns the window caption (title-bar text) of an explorer or inspector window.

Read-only String.

Syntax

object.Caption

object Required. An expression that returns an Explorer or Inspector object.


CardData Property

Returns or sets the text of the card data for the task.

Read/write String.

Syntax

objTaskItem.CardData

objTaskItem Required. An expression that returns a TaskItem object.


CarTelephoneNumber Property

Returns or sets the car telephone number for the contact.

Read/write String.

Syntax

objContactItem.CarTelephoneNumber

objContactItem Required. An expression that returns a ContactItem object.


 Categories Property

Categories Property

Returns or sets the categories assigned to the Outlook item.

Read/write String.

Syntax

object.Categories

object Required. An expression that returns an Outlook object that is in the "Applies To" list.


Category Property

Returns or sets the category assigned to the form description.

Read/write String.

Syntax

objFormDescription.Category

objFormDescription Required. An expression that returns a FormDescription object.


CategorySub Property

Returns or sets the subcategory assigned to the form description.

Read/write String.

Syntax

objFormDescription.CategorySub

objFormDescription Required. An expression that returns a FormDescription object.


CC Property

Returns the display list of carbon copy (CC) names for a MailItem. This property contains the display names only. The Recipients collection should be used to modify the CC recipients.

Read/write String.

Syntax

objMailItem.CC

objMailItem Required. An expression that returns a MailItem object.


Children Property

Returns or sets the names of the children of the contact.

Read/write String.

Syntax

objContactItem.Children

objContactItem Required. An expression that returns a ContactItem object.


 Class Property

Class Property

Returns the OlObjectClass constant for this object. This is a numeric value that identifies the object's class.

Read-only.

Syntax

object.Class

object Required. An expression that returns an Outlook object.


Color Property

Returns or sets the color of the note. Can be one of the following OlNoteColor constants: olBlue(0), olGreen(1), olPink(2), olWhite(4), or olYellow(3).

Read/write Long.

Syntax

objNoteItem.Color

objNoteItem Required. An expression that returns a NoteItem object.


COMAddIns Property

Returns a COMAddIns collection that represents all the Component Object Model (COM) add-ins currently loaded in Microsoft Outlook.

Read-only.

Syntax

obApplication.COMAddIns

objApplication Required. An expression that returns an Application object.


 CommandBars Property

CommandBars Property

Returns a CommandBars collection object that represents all the menus and toolbars in the Explorer or Inspector.

Read-only.

Syntax

object.CommandBars

object Required. An expression that returns an Explorer or Inspector object.


Comment Property

Returns or sets the text of a comment assigned to the form description. Read/write String.

Syntax

objFormDescription.Comment

objFormDescription Required. An expression that returns a FormDescription object.


 Companies Property

Companies Property

Returns or sets the names of the companies associated with the Outlook item. This is a free-form text field.

Read/write String.

Syntax

object.Companies

object Required. An expression that returns an Outlook object.


CompanyAndFullName Property

Returns the concatenated company name and full name for the contact.

Read-only String.

Syntax

objContactItem.CompanyAndFullName

objContactItem Required. An expression that returns a ContactItem object.


CompanyLastFirstNoSpace Property

Returns the company name for the contact followed by the concatenated last name, first name, and middle name with no space between the last and first names. This property is parsed from the CompanyName, LastName, FirstName and MiddleName properties.

Read-only String.

Note: The LastName, FirstName, and MiddleName properties are themselves parsed from the FullName property.

Syntax

objContactItem.CompanyLastFirstNoSpace

objContactItem Required. An expression that returns a ContactItem object.


CompanyLastFirstSpaceOnly Property

Returns the company name for the contact followed by the concatenated last name, first name, and middle name with spaces between the last, first, and middle names. This property is parsed from the CompanyName, LastName, FirstName and MiddleName properties.

Read-only String.

Note: The LastName, FirstName, and MiddleName properties are themselves parsed from the FullName property.

Syntax

objContactItem.CompanyLastFirstSpaceOnly

objContactItem Required. An expression that returns a ContactItem object.


CompanyMainTelephoneNumber Property

Returns or sets the company main telephone number for the contact.

Read/write String.

Syntax

objContactItem.CompanyMainTelephoneNumber

objContactItem Required. An expression that returns a ContactItem object.


CompanyName Property

Returns or sets the company name for the contact.

Read/write String.

Syntax

objContactItem.CompanyName

objContactItem Required. An expression that returns a ContactItem object.


Complete Property

True if the task is completed.

Read/write Boolean.

Syntax

objTaskItem.Complete

objTaskItem Required. An expression that returns a TaskItem object.


ComputerNetworkName Property

Returns or sets the name of the computer network for the contact.

Read/write String.

Syntax

objContactItem.ComputerNetworkName

objContactItem Required. An expression that returns a ContactItem object.


ConferenceServerAllowExternal Property

Reserved for future use.


ConferenceServerPassword Property

Reserved for future use.


 ContactName Property

ContactName Property

Returns or sets the name of the person to contact for information regarding the custom form for this FormDescription object.

Corresponds to the Contact field on the Properties page of a form in design mode.

Read/write String.

Syntax

objFormDescription.ContactName

objFormDescription Required. An expression that returns a FormDescription object.


ContactNames Property

Returns the contact names associated with the journal entry. This property contains the display names for the contacts only. Use the Recipients collection to modify the contents of this string.

Read-only String.

objJournalItem.ContactNames

objJournalItem Required. An expression that returns a JournalItem or TaskItem object.


Contacts Property

Returns the contact names associated with the task. This property contains the display names for the contacts only. Use the Recipients collection to modify the contents of this string.

Read-only String.

Syntax

objTaskItem.Contacts

objTaskItem Required. An expression that returns a TaskItem object.


 Contents Property

Contents Property

Returns the OutlookBarStorage object for the specified Outlook Bar pane.

Read-only.

Syntax

objPane.Contents

objPane Required. An expression that returns an OutlookBarPane object.


 ConversationIndex Property

ConversationIndex Property

Returns the index of the conversation thread of the item.

Read-only String.

Syntax

object.ConversationIndex

object Required. An expression that returns an Outlook object that is in the "Applies To" list.


 ConversationTopic Property

ConversationTopic Property

Returns the topic of the conversation thread of the item.

Read-only String.

Syntax

object.ConversationTopic

object Required. An expression that returns an Outlook object that is in the "Applies To" list.


 CopyLike Property

CopyLike Property

Returns or sets the property inheritance style to use for the action. The inheritance style is used when the action is executed to control how properties are copied to the new item created by the action. Can be one of the following OlActionCopyLike constants: olForward(2), olReply(0), olReplyAll(1), olReplyFolder(3), or olRespond(4).

Read/write Long.

Syntax

objAction.Copy

objAction Required. An expression that returns an Action object.


 Count Property

Count Property

Returns the count of objects in the collection.

Read-only Long.

Syntax

collobject.Count

collobject Required. An expression that returns an Outlook collection object.


 CreationTime Property

CreationTime Property

Returns the creation time for the Outlook item. This property corresponds to the MAPI property PR_CREATION_TIME.

Read-only Date.

Syntax

object.CreationTime

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


CurrentFolder Property

Returns or sets a MAPIFolder object that represents the current folder displayed in the explorer. Use this property to change the folder the user is viewing.

Read/write MAPIFolder.

Syntax

objExplorer.CurrentFolder

objExplorer Required. An expression that returns an Explorer object.


 CurrentGroup Property

CurrentGroup Property

Returns or sets the group that is open in the specified Outlook Bar pane.

Read/write OutlookBarGroup.

Syntax

objPane.CurrentGroup

objPanet Required. An expression that returns an OutlookBarPane object.

Remarks

You must use the Set keyword to set this property, as shown in this example.

Set myOlPane.CurrentGroup = myOlGroup

Setting this property causes the BeforeGroupSwitch event to occur.


 CurrentItem Property

CurrentItem Property

Returns the current item being displayed in the inspector.

Note If there is no currently open item, an error will be returned.

Read-only.

Syntax

objInspector.CurrentItem

objInspector Required. An expression that returns an Inspector object.


CurrentUser Property

Returns the currently logged-on user as a Recipient object. Read-only.

Syntax

objNameSpace.CurrentUser

objNameSpace Required. An expression that returns a NameSpace object.


 CurrentView Property

CurrentView Property

Returns or sets the view for an explorer.

Read/write String.

Syntax

objExplorer.CurrentView

objExplorer Required. An expression that returns an Explorer object.

Remarks

When this property is set, two events occur: BeforeViewSwitch occurs before the actual view change takes place and can be used to cancel the change; ViewSwitch takes place after the change is effective.


CustomerID Property

Returns or sets the customer ID for the contact.

Read/write String.

Syntax

objContactItem.CustomerID

objContactItem Required. An expression that returns a ContactItem object.


DateCompleted Property

Returns or sets the completion date of the task.

Read/write Date.

Syntax

objTaskItem.DateCompleted

objTaskItem Required. An expression that returns a TaskItem object.


DayOfMonth Property

Returns or sets the day of the month on which the recurring appointment or task occurs.

Read/write Long.

Syntax

objRecurrencePattern.DayOfMonth

objRecurrencePattern Required. An expression that returns a RecurrencePattern object.


DayOfWeekMask Property

Returns or sets the mask for the days of the week on which the recurring appointment or task occurs. Monthly and yearly patterns are only valid for a single day. Weekly patterns are only valid as the Or of the DayOfWeekMask. Can be one of or a sum of the following OlDaysOfWeek constants: olSunday(1), olMonday(2), olTuesday(4), olWednesday(8), olThursday(16), olFriday(32), or olSaturday(64).

Read/write Long.

Syntax

objRecurrencePattern.DayOfWeekMask

objRecurrencePattern Required. An expression that returns a RecurrencePattern object.


 DefaultItemType Property

DefaultItemType Property

Returns the default Outlook item type contained in the folder. Can be one of the following OlItemType constants: olAppointmentItem(1), olContactItem(2), olJournalItem(4), olMailItem(0), olNoteItem(5), olPostItem(6), or olTaskItem(3).

Read-only Long.

Syntax

objMAPIFolder.DefaultItemType

objMAPIFolder Required. An expression that returns a MAPIFolder object.


 DefaultMessageClass Property

DefaultMessageClass Property

Returns the default message class for items in the folder.

Read-only String.

Syntax

objMAPIFolder.DefaultMessageClass

objMAPIFolder Required. An expression that returns a MAPIFolder object.


DeferredDeliveryTime Property

Returns or sets the date and time the mail message is to be delivered. This property corresponds to the MAPI property PR_DEFERRED_DELIVERY_TIME.

Read/write Date.

Syntax

objMailItem.DeferredDeliveryTime

objMailItem Required. An expression that returns a MailItem object.


DelegationState Property

Returns the delegation state of the task. Can be one of the following OlTaskDelegationState constants: olTaskDelegationAccepted(2), olTaskDelegationDeclined(3), olTaskDelegationUnknown(1), or olTaskNotDelegated(0).

Read-only Long.

Syntax

objTaskItem.DelegationState

objTaskItem Required. An expression that returns a TaskItem object.


Delegator Property

Returns the display name of the delegator for the task.

Read-only String.

Syntax

objTaskItem.Delegator

objTaskItem Required. An expression that returns a TaskItem object.


DeleteAfterSubmit Property

True if a copy of the mail message is not saved upon being sent. False if a copy is saved.

Read/write Boolean.

Syntax

objMailItem.DeleteAfterSubmit

objMailItem Required. An expression that returns a MailItem object.


Deleted Property

Indicates that the appointment became an exception because it was deleted from the recurring pattern. The Deleted property is True if the AppointmentItem was deleted.

Read-only Boolean.

Syntax

objException.Deleted

objException Required. An expression that returns an Exception object.


Department Property

Returns or sets the department name for the contact.

Corresponds to the Department: field on the Details page of a ContactItem.

Read/write String.

Syntax

objContactItem.Department

objContactItem Required. An expression that returns a ContactItem object.


Description Property

Returns or sets the description of the folder. This property corresponds to the MAPI property PR_COMMENT.

Corresponds to the Description box in the Properties dialog box for the folder.

Read/write String.

Syntax

objMAPIFolder.Description

objMAPIFolder Required. An expression that returns a MAPIFolder object.


Dirty Property

Returns True if the contents of a custom property page have been altered. The ActiveX control that implements the PropertyPage object sets the value of this property, and Microsoft Outlook queries this in response to the OnStatusChange event of a PropertyPageSite object.

Read-only Boolean.

Syntax

objPropertyPage.Dirty

objPropertyPage Required. An expression that returns a PropertyPage object.


DisplayName Property

For Attachment object:

Returns or sets the name, which need not be the actual file name, displayed below the icon representing the embedded attachment. This property corresponds to the MAPI property PR_DISPLAY_NAME.

For FormDescription object:

Returns or sets the name of the form, whish is what will be displayed in the Choose Forms dialog box. If both FormDescription.Name and FormDescription.DisplayName properties are empty, setting one will set the other. If one has been previously set, setting the other will not change the value.

Read/write String.

Syntax

object.DisplayName

object Required. An expression that returns an Attachment or FormDescription object.


DisplayType Property

Returns the OlDisplayType constant that describes the nature of the recipient: olAgent(3), olDistList(1), olForum(2), olOrganization(4), olPrivateDistList(5), olRemoteUser(6), olUser(0).

You can use the DisplayType property to filter recipients. The DisplayType property corresponds to the MAPI property PR_DISPLAY_TYPE.

Read-only.

Syntax

object.DisplayType

object Required. An expression that returns an AddressEntry or Recipient object.


DLName Property

Returns or sets the display name of a distribution list.

Read/write String.

Syntax

objDistListItem.DLName

objDistListItem Required. An expression that returns a DistListItem object.


 DocPosted Property

DocPosted Property

True if the journalized item was posted as part of the journalized session.

Read/write Boolean.

Syntax

objJournalItem.DocPosted

objJournalItem Required. An expression that returns a JournalItem object.


 DocPrinted Property

DocPrinted Property

True if the journalized item was printed as part of the journalized session.

Read/write Boolean.

Syntax

objJournalItem.DocPrinted

objJournalItem Required. An expression that returns a JournalItem object.


 DocRouted Property

DocRouted Property

True if the journalized item was routed as part of the journalized session.

Read/write Boolean.

Syntax

objJournalItem.DocRouted

objJournalItem Required. An expression that returns a JournalItem object.


 DocSaved Property

DocSaved Property

True if the journalized item was saved as part of the journalized session.

Read/write Boolean.

Syntax

objJournalItem.DocSaved

objJournalItem Required. An expression that returns a JournalItem object.


DueDate Property

Returns or sets the due date for the task.

Read/write Date.

Syntax

objTaskItem.DueDate

objTaskItem Required. An expression that returns a TaskItem object.


Duration Property

Returns or sets the duration (in minutes) of the appointment, journal entry, or recurrence pattern. For recurrences, this property is only valid for appointments.

Read/write Long.

Syntax

object.Duration

object Required. An expression that returns an AppointmentItem, RecurrencePattern, or JournalItem object.


 EditorType Property

EditorType Property

Returns the OlEditorType constant for this item: olEditorHTML(2), olEditorRTF(3), olEditorText(1), or olEditorWord(4).

Note The EditorType property is not affected when you merely access the Body property of the item (as in MsgBox myItem.Body), but when you reset the Body property (as in myItem.Body = "This is a new body"), the EditorType reverts back to the user's default editor.

Read-only.

Syntax

objInspector.EditorType

objInspector Required. An expression that returns an Inspector object.


Email1Address Property

Returns or sets the e-mail address of the first e-mail entry for the contact.

Read/write String.

Syntax

objContactItem.Email1Address

objContactItem Required. An expression that returns a ContactItem object.


Email1AddressType Property

Returns or sets the address type (such as EX or SMTP) of the first e-mail entry for the contact. This is a free-form text field, but it must match the actual type of an existing mail transport.

Read/write String.

Syntax

objContactItem.Email1AddressType

objContactItem Required. An expression that returns a ContactItem object.


Email1DisplayName Property

Returns the display name of the first e-mail address for the contact. This property is set to the value of the FullName property by default.

Read-only String.

Syntax

objContactItem.Email1DisplayName

objContactItem Required. An expression that returns a ContactItem object.


Email1EntryID Property

Returns the entry ID of the first e-mail address for the contact.

Read-only String.

Syntax

objContactItem.Email1EntryID

objContactItem Required. An expression that returns a ContactItem object.


Email2Address Property

Returns or sets the e-mail address of the second e-mail entry for the contact.

Read/write String.

Syntax

objContactItem.Email2Address

objContactItem Required. An expression that returns a ContactItem object.


Email2AddressType Property

Returns or sets the address type (such as EX or SMTP) of the second e-mail entry for the contact. This is a free-form text field, but it must match the actual type of an existing mail transport.

Read/write String.

Syntax

objContactItem.Email2AddressType

objContactItem Required. An expression that returns a ContactItem object.


Email2DisplayName Property

Returns the display name of the second e-mail entry for the contact. This property is set to the value of the FullName property by default.

Read-only String.

Syntax

objContactItem.Email2DisplayName

objContactItem Required. An expression that returns a ContactItem object.


Email2EntryID Property

Returns the entry ID of the second e-mail entry for the contact.

Read-only String.

Syntax

objContactItem.Email2EntryID

objContactItem Required. An expression that returns a ContactItem object.


Email3Address Property

Returns or sets the e-mail address of the third e-mail entry for the contact.

Read/write String.

Syntax

objContactItem.Email3Address

objContactItem Required. An expression that returns a ContactItem object.


Email3AddressType Property

Returns or sets the address type (such as EX or SMTP) of the third e-mail entry for the contact. This is a free-form text field, but it must match the actual type of an existing mail transport.

Read/write String.

Syntax

objContactItem.Email3AddressType

objContactItem Required. An expression that returns a ContactItem object.


Email3DisplayName Property

Returns the display name of the third e-mail entry for the contact. This property is set to the value of the FullName property by default.

Read-only String.

Syntax

objContactItem.Email3DisplayName

objContactItem Required. An expression that returns a ContactItem object.


Email3EntryID Property

Returns the entry ID of the third e-mail entry for the contact.

Read-only String.

Syntax

objContactItem.Email3EntryID

objContactItem Required. An expression that returns a ContactItem object.


Enabled Property

True if the action is enabled in the application.

Read/write Boolean.

Syntax

objAction.Enabled

objAction Required. An expression that returns an Action object.


End Property

Returns or sets the end date and time of an appointment or journal entry.

Read/write Date.

Syntax

object.End

object Required. An expression that returns an AppointmentItem or a JournalItem object.


EndTime Property

Returns or sets the end time for a recurrence pattern. This property is only valid for appointments.

Read/write Date.

Syntax

objRecurrencePattern.End

objRecurrencePattern Required. An expression that returns a RecurrencePattern object.


 EntryID Property

EntryID Property

Returns the unique entry ID of the object. This property corresponds to the MAPI property PR_ENTRYID. MAPI systems assign a permanent, unique ID string when an object is created that does not change from one MAPI session to another. The EntryID property is not set for an Outlook item until it is saved or sent. Also, the EntryID changes when an item is moved into another folder.

Read-only String.

Syntax

object.EntryID

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


Exceptions Property

Returns the Exceptions collection for that particular series of recurring appointments.

Read-only.

Syntax

objRecurrencePattern.Exceptions

objRecurrencePattern Required. An expression that returns a RecurrencePattern object.


 ExpiryTime Property

ExpiryTime Property

Returns or sets the date and time at which the item becomes invalid and can be deleted.

Read/write Date.

Syntax

object.ExpiryTime

object Required. An expression that returns a MailItem, MeetingItem, or PostItem object.


 Explorers Property

Explorers Property

Returns an Explorers collection object that contains the Explorer objects representing all open explorers.

Read-only.

Syntax

objApplication.Explorers

objApplication Required. An expression that returns an Application object.


FileAs Property

Returns or sets the default keyword string assigned to the contact when it is filed.

Read/write String.

Syntax

objContactItem.FileAs

objContactItem Required. An expression that returns a ContactItem object.


FileName Property

Returns the file name of the attachment. Use this property in conjunction with the PathName property.

Read-only String.

Syntax

objAttachment.FileName

objAttachment Required. An expression that returns an Attachment object.


FirstName Property

Returns or sets the first name for the contact.

Read/write String.

Syntax

objContactItem.FirstName

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the FullName property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes of entries to FullName.


FlagDueBy Property

Returns or sets the date by which this mail message is due. This property is only valid if the FlagStatus property is also set for the message. This property corresponds to the MAPI property PR_REPLY_TIME.

Read/write Date.

Syntax

objMailItem.FlagDueBy

objContactItem Required. An expression that returns a MailItem object.


FlagRequest Property

Returns or sets the requested action for the mail message. This is a free-form text field. This property is only valid if the FlagStatus property is also set for the message.

Read/write String.

Syntax

objMailItem.FlagRequest

objMailItem Required. An expression that returns a MailItem object.


FlagStatus Property

Returns or sets the flag status for the mail message. Can be one of the following OlFlagStatus constants: olFlagComplete(1), olFlagMarked(2), or olNoFlag(0).

Read/write Long.

Syntax

objMailItem.FlagStatus

objMailItem Required. An expression that returns a MailItem object.


Folders Property

Returns the Folders collection that represents all the folders contained in the specified folder or name space. The NameSpace object is the root of all the folders for the given name space.

Read-only.

Syntax

object.Folders

object Required. An expression that returns a MAPIFolder object or a NameSpace object.


 FormDescription Property

FormDescription Property

Returns the FormDescription object that represents the form description for the Outlook item.

Read-only.

Syntax

object.FormDescription

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


Formula Property

Returns or sets the formula for the user property.

Read/write String.

Syntax

objUserProperty.Formula

objUserProperty Required. An expression that returns a UserProperty object.


FTPSite Property

Returns the FTP site entry for the contact.

Read/write String.

Syntax

objContactItem.FTPSite

objContactItem Required. An expression that returns a ContactItem object.


FullName Property

Returns or sets the whole, unparsed full name for the contact.

Read/write String.

Syntax

objContactItem.FullName

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed into the FirstName, LastName, MiddleName, and Suffix properties, which may be changed or entered independently should they be parsed incorrectly. Note that any such changes or entries to the FirstName, LastName, MiddleName or Suffix properties will be overwritten by any subsequent changes or entries to FullName.


FullNameAndCompany Property

Returns the full name and company of the contact by concatenating the values of the FullName and CompanyName properties.

Read-only String.

Syntax

objContactItem.FullNameAndCompany

objContactItem Required. An expression that returns a ContactItem object.


Gender Property

Returns or sets the gender of the contact. Can be one of the following OlGender constants: olFemale(1), olMale(2), or olUnspecified(0).

Read/write Long.

Syntax

objContactItem.Gender

objContactItem Required. An expression that returns a ContactItem object.


 GetInspector Property

GetInspector Property

Returns an Inspector object that represents an inspector initialized to contain the specified item. This property is useful for returning a new Inspector object in which to display the item, as opposed to using the ActiveInspector method and setting the CurrentItem property.

Read-only Inspector.

Syntax

object.GetInspector

object Required. An expression that returns an item object that is in the "Applies To" list.

The Inspector Object and Microsoft Word as the User’s E-mail Editor

If the user’s default e-mail editor is Microsoft Word, and if the message format of the item being edited is plain text or HTML, GetInspector produces an error and returns Nothing.


GovernmentIDNumber Property

Returns or sets the government ID number for the contact.

Read/write String.

Syntax

objContactItem.GovernmentIDNumber

objContactItem Required. An expression that returns a ContactItem object.


 Groups Property

Groups Property

Returns the set of groups in an Outlook Bar.

Read-only OutlookBarGroups

Syntax

objOLBarStorage.Groups

objOLBarStorage Required. An expression that returns an OutlookBarStorage object.


HasAttachment Property

True if the remote item has an attachment associated with it. The default value is True.

Read-only Boolean.

Syntax

objRemoteItem.HasAttachment

objRemoteItem Required. An expression that returns a RemoteItem object.


Height Property

Returns or sets the height (in pixels) of the explorer, inspector, or note window.

Read/write Long.

Syntax

object.Height

object Required. An expression that returns an Explorer, Inspector, or NoteItem object.


 Hidden Property

Hidden Property

The Hidden property corresponds to the Use form only for responses check box on the Properties page of the form in design mode.

Setting this property to True causes the custom form to be hidden. It will not appear on the menu or in the Choose Form dialog box and will be used only if it is designated as the response form from another custom form.

The default value is False.

Read/write Boolean.

Syntax

objFormDescription.Hidden

objFormDescription Required. An expression that returns a FormDescription object.


Hobby Property

Returns or sets the hobby for the contact.

Read/write String.

Syntax

objContactItem.Hobby

objContactItem Required. An expression that returns a ContactItem object.


Home2TelephoneNumber Property

Returns or sets the second home telephone number for the contact.

Read/write String.

Syntax

objContactItem.Home2TelephoneNumber

objContactItem Required. An expression that returns a ContactItem object.


HomeAddress Property

Returns or sets the full, unparsed text of the home address for the contact.

Read/write String.

Syntax

objContactItem.HomeAddress

objContactItem Required. An expression that returns a ContactItem object.


HomeAddressCity Property

Returns or sets the city portion of the home address for the contact.

Read/write String.

Syntax

objContactItem.HomeAddressCity

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the HomeAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to HomeAddress.


HomeAddressCountry Property

Returns or sets the country portion of the home address for the contact.

Read/write String.

Syntax

objContactItem.HomeAddressCountry

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the HomeAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to HomeAddress.


HomeAddressPostalCode Property

Returns or sets the postal code portion of the home address for the contact.

Read/write String.

Syntax

objContactItem.HomeAddressPostalCode

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the HomeAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to HomeAddress.


HomeAddressPostOfficeBox Property

Returns or sets the post office box number portion of the home address for the contact.

Read/write String.

Syntax

objContactItem.HomeAddressPostOfficeBox

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the HomeAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to HomeAddress.


HomeAddressState Property

Returns or sets the state portion of the home address for the contact.

Read/write String.

Syntax

objContactItem.HomeAddressState

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the HomeAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to HomeAddress.


HomeAddressStreet Property

Returns or sets the street portion of the home address for the contact.

Read/write String.

Syntax

objContactItem.HomeAddressStreet

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the HomeAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to HomeAddress.


HomeFaxNumber Property

Returns or sets the home fax number for the contact.

Read/write String.

Syntax

objContactItem.HomeFaxNumber

objContactItem Required. An expression that returns a ContactItem object.


HomeTelephoneNumber Property

Returns or sets the first home telephone number for the contact.

Read/write String.

Syntax

objContactItem.HomeTelephoneNumber

objContactItem Required. An expression that returns a ContactItem object.


 HTMLBody Property

HTMLBody Property

Sets the HTML body of the item. The HTMLBody property should be an HTML syntax string.

Setting the HTMLBody property sets the EditorType property of the item's Inspector to olEditorHTML(2).

Setting the HTMLBody property will always update the Body property immediately.

Setting the Body property will clear the contents of the HTMLBody property on HTML aware stores (Internet Only Mode).

Note The EditorType property is not affected when you merely access the Body property of the item (as in MsgBox myItem.Body), but when you reset the Body property (as in myItem.Body = "This is a new body"), the EditorType reverts back to the user's default editor.

Read/write String.

Syntax

object.HTMLBody

object Required. An expression that returns a PostItem or MailItem object.


 HTMLEditor Property

HTMLEditor Property

Returns the HTML Document Object Model of the message being displayed. The HTML Document Object Model is defined by Internet Explorer and is the same one used for Dynamic HTML. This object may be temporary and should not be stored for later use.

The HTMLEditor property is only valid if the EditorType property of the item's associated Inspector is set to olEditorHTML(2).

Read-only.

Syntax

objInspector.HTMLEditor

objInspector Required. An expression that returns an Inspector object.


Icon Property

Returns or sets the file name of the icon to be displayed for the form.

Read/write String.

Syntax

objFormDescription.Icon

objFormDescription Required. An expression that returns a FormDescription object.


 ID Property

ID Property

Returns the unique identifier for the object. The transport provider assigns a permanent, unique string ID property when an individual member object is created. These identifiers do not change from one session to another.

Read-only String.

Syntax

object.ID

object Required. An expression that returns an AddressEntry or AddressList object.


 Importance Property

Importance Property

Returns or sets the relative importance level for the Outlook item. Can be one of the following OlImportance constants: olImportanceHigh(2), olImportanceLow(0), or olImportanceNormal(1). This property corresponds to the MAPI property PR_IMPORTANCE.

Read/write Long.

Syntax

object.Importance

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


IncludeRecurrences Property

True if the Items collection should include recurrence patterns. This property only has an effect if the Items collection contains appointments and is not sorted by any property other than Start in ascending order. The default value is False.

Read/write Boolean.

Syntax

objItems.IncludeRecurrences

objItems Required. An expression that returns an Items collection object.

Remarks

Use this property when you want to retrieve all appointments for a given date, where recurring appointments would not normally appear because they are not associated with any specific date. If the collection includes recurring appointments with no end date, setting the property to True may cause the collection to be of infinite count. Be sure to include a test for this in any loop.


 Index Property

Index Property

Returns the position of the object within the collection. The Index property is only valid during the current session and can change as objects are added to and deleted from the collection. The first object in the collection has an Index value of 1.

Read-only Long.

Syntax

object.Index

object Required. An expression that returns an AddressList, Attachment, or Recipient object.


Initials Property

Returns or sets the initials for the contact.

Read/write String.

Syntax

objContactItem.Initials

objContactItem Required. An expression that returns a ContactItem object.


 Inspectors Property

Inspectors Property

Returns an Inspectors collection object that contains the Inspector objects representing all open inspectors.

Read-only.

Syntax

objApplication.Inspectors

objApplication Required. An expression that returns an Application object.


Instance Property

Returns or sets the count for which the recurrence pattern is valid for a given interval. This property is only valid for recurrences of the olRecursMonthNth(3) and olRecursYearNth(6) type and allows the definition of a recurrence pattern that is only valid for the Nth occurrence, such as "the 2nd Sunday in March" pattern. The count is set numerically: 1 for the first, 2 for the second, and so on through 5 for the last. Values greater than 5 will generate errors when the pattern is saved.

Read/write Long.

Syntax

objRecurrencePattern.Instance

objRecurrencePattern Required. An expression that returns a RecurrencePattern object.


InternetFreeBusyAddress Property

The InternetFreeBusyAddress property refers to the reading and publishing of a calendar user's free/busy map of events. The map is retrieved when a user plans a meeting. This property corresponds to a field in the details page for an Internet Only contact. This field can contain the URL location of the user's free/busy information in vCard Free/Busy standard format.

Read/write String.

Syntax

objContactItem.InternetFreeBusyAddress

objContactItem Required. An expression that returns a ContactItem object.

Note This property is only applicable for Internet Only support users.


Interval Property

Returns or sets the number of units of a given recurrence type between occurrences. For example, setting the Interval property to 2 and the RecurrenceType property to "Weekly" would cause the pattern to occur every second week.

Note The Interval property must be set before setting PatternEndDate. Also, the Interval property is not valid for yearly recurrence patterns.

Read/write Long.

Syntax

objRecurrencePattern.Interval

objRecurrencePattern Required. An expression that returns a RecurrencePattern object.


ISDNNumber Property

Returns or sets the ISDN number for the contact.

Read/write String.

Syntax

objContactItem.ISDNNumber

objContactItem Required. An expression that returns a ContactItem object.


IsOnlineMeeting Property

This property corresponds to the This is an online meeting checkbox on the Appointment page and to the corresponding This is an online meeting using checkbox on the Online page of a meeting item.

True if this is an online meeting.

Boolean.

Syntax

objAppointmentItem.IsOnlineMeeting

objAppointmentItem Required. An expression that returns an AppointmentItem object.


IsReadOnly Property

Indicates that the AddressList object cannot be modified. The IsReadOnly property refers to adding and deleting the entries in the address book container represented by the AddressList object. The property is True if no entries can be added or deleted. The property is False if the container can be modified, that is, if address entries can be added to and deleted from the container.

IsReadOnly refers to the address book entries in the context of the address book container. It does not indicate whether the contents of the individual entries themselves can be modified.

Read-only Boolean.

Syntax

objAddressList.IsReadOnly

objAddressList Required. An expression that returns an AddressList object.


IsRecurring Property

True if the appointment or task is a recurring appointment or task. When the GetRecurrencePattern method is used with an AppointmentItem or TaskItem object, this property is set to True.

Read-only Boolean.

Syntax

object.IsRecurring

object Required. An expression that returns a TaskItem or an AppointmentItem object.


Item Property

Returns the Microsoft Outlook item that is represented by a Link object.

Read-only Object.

Syntax

objLink.Item

objLink Required. An expression that returns a Link object.


 Items Property

Items Property

Returns the collection of Outlook items in the folder.

Read-only Items.

Syntax

objMAPIFolder.Items

objMAPIFolder Required. An expression that returns a MAPIFolder object.


JobTitle Property

Returns or sets the job title for the contact.

Read/write String.

Syntax

objContactItem.JobTitle

objContactItem Required. An expression that returns a ContactItem object.


Journal Property

True if the transaction of the contact will be journalized. The default value is False.

Read/write Boolean.

Syntax

objContactItem.Journal

objContactItem Required. An expression that returns a ContactItem object.


Language Property

Returns or sets the language for the contact.

Read/write String.

Syntax

objContactItem.Language

objContactItem Required. An expression that returns a ContactItem object.


LanguageSettings Property

Returns a LanguageSettings object for the application that contains the language-specific attributes of Microsoft Outlook.

Read-only LanguageSettings

Syntax

object.LanguageSettings()

object Required. An expression that returns an Application object.


LastFirstAndSuffix Property

Returns the last name, first name, middle name, and suffix of the contact. There is a comma between the last and first names and spaces between all the names and the suffix. This property is parsed from the LastName, FirstName, MiddleName and Suffix properties.

Read-only String.

Note: The LastName, FirstName, MiddleName, and Suffix properties are themselves parsed from the FullName property.

Syntax

objContactItem.LastFirstAndSuffix

objContactItem Required. An expression that returns a ContactItem object.


LastFirstNoSpace Property

Returns the concatenated last name, first name, and middle name of the contact with no space between the last name and the first name. This property is parsed from the LastName, FirstName and MiddleName properties.

Read-only String.

Note: The LastName, FirstName, and MiddleName properties are themselves parsed from the FullName property.

Syntax

objContactItem.LastFirstNoSpace

objContactItem Required. An expression that returns a ContactItem object.


LastFirstNoSpaceCompany Property

Returns the concatenated last name, first name, and middle name of the contact with no space between the last name and the first name. The company name for the contact is included after the middle name. This property is parsed from the LastName, FirstName, MiddleName, and CompanyName properties.

Read-only String.

Note: The LastName, FirstName, and MiddleName properties are themselves parsed from the FullName property.

Syntax

objContactItem.LastFirstNoSpaceCompany

objContactItem Required. An expression that returns a ContactItem object.


LastFirstSpaceOnly Property

Returns the concatenated last name, first name, and middle name of the contact with spaces between them. This property is parsed from the LastName, FirstName and MiddleName properties.

Read-only String.

Note: The LastName, FirstName, and MiddleName properties are themselves parsed from the FullName property.

Syntax

objContactItem.LastFirstSpaceOnly

objContactItem Required. An expression that returns a ContactItem object.


LastFirstSpaceOnlyCompany Property

Returns the concatenated last name, first name, and middle name of the contact with spaces between them. The company name for the contact is after the middle name. This property is parsed from the LastName, FirstName, MiddleName, and CompanyName properties.

Read-only String.

Note: The LastName, FirstName, and MiddleName properties are themselves parsed from the FullName property.

Syntax

objContactItem.LastFirstSpaceOnlyCompany

objContactItem Required. An expression that returns a ContactItem object.


 LastModificationTime Property

LastModificationTime Property

Returns the time that the Outlook item was last modified. This property corresponds to the MAPI property PR_LAST_MODIFICATION_TIME.

Read-only Date.

Syntax

object.LastModificationTime

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


LastName Property

Returns or sets the last name for the contact.

Read/write String.

Syntax

objContactItem.LastName

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the FullName property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes of entries to FullName.


LastNameAndFirstName Property

Returns the concatenated last name and first name for the contact.

Read-only String.

Syntax

objContactItem.LastNameAndFirstName

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the FirstName and LastName properties for the contact, which are themselves parsed from the FullName property.


Left Property

Returns or sets the position (in pixels) of the left vertical edge of an explorer, inspector, or note window from the edge of the screen.

Read/write Long.

Syntax

object.Left

object Required. An expression that returns an Explorer, Inspector, or NoteItem object.


Links Property

Returns a collection of Link objects that represent the contacts to which the item is linked.

Read-only Links.

Syntax

objOutlookItem.Links

object Required. An expression that returns a Microsoft Outlook item object.


Location Property

Returns or sets the specific office location (for example, Building 1 Room 1 or Suite 123) for the appointment. This property corresponds to the MAPI property PR_OFFICE_LOCATION.

Read/write String.

Syntax

objAppointmentItem.Location

objAppointmentItem Required. An expression that returns an AppointmentItem object.


Locked Property

True if the form cannot be modified.

Read/write Boolean.

Syntax

object.Locked

object Required. An expression that returns a FormDescription object.


MailingAddress Property

Returns or sets the full, unparsed selected mailing address for the contact.

Read/write String.

Syntax

objContactItem.MailingAddress

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property replicates the property indicated by the SelectedMailingAddress property, which is one of the following OlMailingAddress constants: olBusiness(2), olHome(1), olNone(0), or olOther(3). While it can be changed or entered independently, any such changes or entries to this property will be overwritten by any subsequent changes or entries to the property indicated by SelectedMailingAddress.


MailingAddressCity Property

Returns or sets the city name portion of the selected mailing address of the contact.

Read/write String.

Syntax

objContactItem.MailingAddressCity

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property replicates the property indicated by the SelectedMailingAddress property, which is one of the following OlMailingAddress constants: olBusiness(2), olHome(1), olNone(0), or olOther(3). While it can be changed or entered independently, any such changes or entries to this property will be overwritten by any subsequent changes or entries to the property indicated by SelectedMailingAddress.


MailingAddressCountry Property

Returns or sets the country code portion of the selected mailing address of the contact.

Read/write String.

Syntax

objContactItem.MailingAddressCountry

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property replicates the property indicated by the SelectedMailingAddress property, which is one of the following OlMailingAddress constants: olBusiness(2), olHome(1), olNone(0), or olOther(3). While it can be changed or entered independently, any such changes or entries to this property will be overwritten by any subsequent changes or entries to the property indicated by SelectedMailingAddress.


MailingAddressPostalCode Property

Returns or sets the postal code (zip code) portion of the selected mailing address of the contact.

Read/write String.

Syntax

objContactItem.MailingAddressPostalCode

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property replicates the property indicated by the SelectedMailingAddress property, which is one of the following OlMailingAddress constants: olBusiness(2), olHome(1), olNone(0), or olOther(3). While it can be changed or entered independently, any such changes or entries to this property will be overwritten by any subsequent changes or entries to the property indicated by SelectedMailingAddress.


MailingAddressPostOfficeBox Property

Returns or sets the post office box number portion of the selected mailing address of the contact.

Read/write String.

Syntax

objContactItem.MailingAddressPostOfficeBox

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property replicates the property indicated by the SelectedMailingAddress property, which is one of the following OlMailingAddress constants: olBusiness(2), olHome(1), olNone(0), or olOther(3). While it can be changed or entered independently, any such changes or entries to this property will be overwritten by any subsequent changes or entries to the property indicated by SelectedMailingAddress.


MailingAddressState Property

Returns or sets the state code portion for the selected mailing address of the contact.

Read/write String.

Syntax

objContactItem.MailingAddressState

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property replicates the property indicated by the SelectedMailingAddress property, which is one of the following OlMailingAddress constants: olBusiness(2), olHome(1), olNone(0), or olOther(3). While it can be changed or entered independently, any such changes or entries to this property will be overwritten by any subsequent changes or entries to the property indicated by SelectedMailingAddress.


MailingAddressStreet Property

Returns or sets the street address portion of the selected mailing address of the contact.

Read/write String.

Syntax

objContactItem.MailingAddressStreet

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property replicates the property indicated by the SelectedMailingAddress property, which is one of the following OlMailingAddress constants: olBusiness(2), olHome(1), olNone(0), or olOther(3). While it can be changed or entered independently, any such changes or entries to this property will be overwritten by any subsequent changes or entries to the property indicated by SelectedMailingAddress.


Manager Property

Returns an AddressEntry object that represents the manager of the user that corresponds to this address entry. If the user's manager is not available in the messaging system, the Manager property returns Nothing.

Read-only.

Syntax

objAddressEntry.Manager

objAddressEntry Required. An expression that returns an AddressEntry object.


ManagerName Property

Returns or sets the manager name for the contact.

Read/write String.

Syntax

objContactItem.ManagerName

objContactItem Required. An expression that returns a ContactItem object.


MeetingResponseStatus Property

Returns the overall status of the response to the meeting request for the recipient. Can be one of the following OlResponseStatus constants: olResponseAccepted(3), olResponseDeclined(4), olResponseNone(0), olResponseNotResponded(5), olResponseOrganized(1), or olResponseTentative(2).

Read-only Long.

Syntax

objRecipient.MeetingResponseStatus

objRecipient Required. An expression that returns a Recipient object.


MeetingStatus Property

Returns or sets the meeting status of the appointment. Use this property to make a MeetingItem object available for the appointment. Can be one of the following OlMeetingStatus constants: olMeeting(1), olMeetingCanceled(5), olMeetingReceived(3), or olNonMeeting(0).

Read/write Long.

Syntax

objAppointmentItem.MeetingStatus

objAppointmentItem Required. An expression that returns an AppointmentItem object.


MemberCount Property

Returns the number of members in a distribution list.

Read-only Long.

Syntax

objDistListItem.MemberCount)

objDistListItem Required. An expression that returns a DistListItem object.

Remarks

The value returned represents all members of the distribution list, including member distribution lists. Each member distribution list is counted as a single member. That is, MemberCount is not an aggregate sum of the recipients in the distribution list plus recipients in member distribution lists. For example, if a distribution list contains 10 recipients plus one distribution list containing 15 recipients, MemberCount returns 11.


 Members Property

Members Property

Returns an AddressEntries collection object representing the members of a distribution list in an address book.

A distribution list is an AddressEntry object whose DisplayType property is set to olDistList(1) or olPrivateDistList(5).

The Members property returns Nothing if the AddressEntry is not a distribution list.

Read-only AddressEntries.

Syntax

objAddressEntry.Members

objAddressEntry Required. An expression that returns an AddressEntry object.


 MessageClass Property

MessageClass Property

Returns or sets the message class for the Outlook item or Action. This property corresponds to the MAPI property PR_MESSAGE_CLASS. The MessageClass property links the item to the form on which it is based. When an item is selected, Outlook uses the message class to locate the form and expose its properties, such as Reply commands.

Read/write String.

Syntax

object.MessageClass

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


MiddleName Property

Returns or sets the middle name for the contact.

Read/write String.

Syntax

objContactItem.MiddleName

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the FullName property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes of entries to FullName.


 Mileage Property

Mileage Property

Returns or sets the mileage for an item . This is a free-form string field and can be used to store mileage information associated with the item (for example, 100 miles documented for an appointment, contact, or task) for purposes of reimbursement.

Read/write String.

Syntax

object.Mileage

object Required. An expression that returns an Outlook item object that is listed in the "Applies To" list.


MiniIcon Property

Returns or sets the file name of the mini-icon to be displayed for the form.

Read/write String.

Syntax

objFormDescription.MiniIcon

objFormDescription Required. An expression that returns a FormDescription object.


MobileTelephoneNumber Property

Returns or sets the mobile telephone number for the contact.

Read/write String.

Syntax

objContactItem.MobileTelephoneNumber

objContactItem Required. An expression that returns a ContactItem object.


 ModifiedFormPages Property

ModifiedFormPages Property

Returns the Pages collection that represents all the pages for the item in the inspector. The main page and up to five customizable pages can be obtained using the Add method.

Read-only.

Syntax

objInspector.ModifiedFormPages

objInspector Required. An expression that returns an Inspector object.


MonthOfYear Property

Returns or sets which month of the year is valid for this recurrence pattern. Can be a number from 1 through 12. For example, setting this property to 5 and the RecurrenceType property to olRecursYearly(5) would cause this recurrence pattern to occur every May.

Read/write Long.

Syntax

objRecurrencePattern.MonthOfYear

objRecurrencePattern Required. An expression that returns a RecurrencePattern object.

Note This property is only valid for recurrence patterns whose RecurrenceType property is set to olRecursYearly(5) or olRecursYearNth(6).


 Name Property

Name Property

Returns or sets the display name for the item. The Name property is also the caption for a form.

Read-only String for Application, AddressList, Link, Recipient, OutlookBarGroup, OutlookBarPane, OutlookBarShortcut, SyncObject, and UserProperty objects.

Read/write String for Action, AddressEntry, FormDescription, and MAPIFolder objects.

Syntax

object.Name

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.

Note The Name property must be set before you can use the PublishForm method. It is also necessary for the Name property to be set before calling the Details method.


NetMeetingAlias Property

Indicates the user's NetMeeting ID, or alias.

Read/write String.

Syntax

objContactItem.NetMeetingAlias

objContactItem Required. An expression that returns a ContactItem object.


NetMeetingAutoStart Property

This property corresponds to the checkbox on the Online page of an online meeting item that is labeled Automatically start NetMeeting 15 minutes. True if this online meeting starts automatically.

Read/write Boolean.

Syntax

objAppointmentItem.NetMeetingAutoStart

objAppointmentItem Required. An expression that returns an AppointmentItem object.


 NetMeetingDocPathName Property

NetMeetingDocPathName Property

Returns or sets the full path to the Microsoft Office document specified for a NetMeeting online meeting.

Read/write String.

Syntax

objAppointmentItem.NetMeetingDocPathName

objAppointmentItem Required. An expression that returns an AppointmentItem object.


NetMeetingOrganizerAlias Property

This property corresponds to the Organizer's e-mail address field on the Online page of an online meeting item. Contains the alias of the meeting organizer if this is an Online meeting.

Read/write String.

Syntax

objAppointmentItem.NetMeetingOrganizerAlias

objAppointmentItem Required. An expression that returns an AppointmentItem object.


NetMeetingServer Property

This property corresponds to the Directory Server field on the Online page of an online meeting item. Contains the name of the NetMeeting server being used for the Online meeting.

Read/write String.

Syntax

object.NetMeetingServer

object Required. An expression that returns an AppointmentItem or ContactItem object.


NetMeetingType Property

This property corresponds to the NetMeeting type drop-down list box on the Online page of an online meeting item. Can be one of the OlNetMeetingType constants: olChat(2), olNetMeeting(0), or olNetShow(1).

Read/write String.

Syntax

objAppointmentItem.NetMeetingType

objAppointmentItem Required. An expression that returns an AppointmentItem object.


NetShowURL Property

Returns or sets the URL for a Microsoft NetShow online meeting.

Read/write String.

Syntax

objAppointmentItem.NetShowURL

objAppointmentItem Required. An expression that returns an AppointmentItem object.


NickName Property

Returns or sets the nickname for the contact.

Read/write String.

Syntax

objContactItem.Nickname

objContactItem Required. An expression that returns a ContactItem object.


 NoAging Property

NoAging Property

True to not age the Outlook item.

Read/write Boolean.

Syntax

object.NoAging

object Required. An expression that returns an Outlook item object that is listed in the "Applies To" list.


NoEndDate Property

True if the recurrence pattern has no end date.

Read/write Boolean.

Syntax

objRecurrencePattern.NoEndDate

objRecurrencePattern Required. An expression that returns a RecurrencePattern object.

Remarks

This property must be coordinated with other properties when setting up a recurrence pattern. If the PatternEndDate property or the Occurrences property is set, the pattern is considered to be finite and the NoEndDate property is False. If neither PatternEndDate nor Occurrences is set, the pattern is considered infinite and NoEndDate is True.


 Number Property

Number Property

Returns or sets the number for the form.

Corresponds to the Form Number: box on the Properties page of the form in design mode.

Read/write String.

Syntax

objFormDescription.Number

objFormDescription Required. An expression that returns a FormDescription object.


Occurrences Property

Returns or sets the number of occurrences of the recurrence pattern. This property allows the definition of a recurrence pattern that is only valid for the specified number of subsequent occurrences. For example, you can set this property to 10 for a formal training course that will be held on the next ten Thursday evenings.

Corresponds to the End after: check box and occurrences text box on the Appointment Recurrence dialog box that appears when you click Recurrence… on a meeting request.

Read/write Long.

Syntax

objRecurrencePattern.Occurrences

objRecurrencePattern Required. An expression that returns a RecurrencePattern object.

Remarks

This property must be coordinated with other properties when setting up a recurrence pattern. If the PatternEndDate property or the Occurrences property is set, the pattern is considered to be finite and the NoEndDate property is False. If neither PatternEndDate nor Occurrences is set, the pattern is considered infinite and NoEndDate is True.


OfficeLocation Property

Returns or sets the specific office location (for example, Building 1 Room 1 or Suite 123) for the contact. This property corresponds to the MAPI property PR_OFFICE_LOCATION.

Read/write String.

Syntax

objContactItem.OfficeLocation

objContactItem Required. An expression that returns a ContactItem object.


OneOff Property

True if the form will be discarded after using once (one-off). False if the form is retained as a custom form.

Read/write Boolean.

Syntax

objFormDescription.OneOff

objFormDescription Required. An expression that returns a FormDescription object.


OptionalAttendees Property

Returns the display string of optional attendees names for the appointment. This property corresponds to the MAPI property PR_DISPLAY_CC.

When you click the Invite Others… button on the Attendee Availability page of a meeting request, the Select Attendees and Resources dialog box appears. If you type in or select a name from the list and then click the Optional button, this attendee is now an optional attendee.

Read-only String.

Syntax

objAppointmentItem.OptionalAttendees

objAppointmentItem Required. An expression that returns an AppointmentItem object.


Ordinal Property

Returns or sets the position in the view (ordinal) for the task.

Read/write Long.

Syntax

objTaskItem.Ordinal

objTaskItem Required. An expression that returns a TaskItem object.


OrganizationalIDNumber Property

Returns or sets the organizational ID number for the contact.

Read/write String.

Syntax

objContactItem.OrganizationalIDNumber

objContactItem Required. An expression that returns a ContactItem object.


Organizer Property

Returns the name of the organizer of the appointment.

Read-only String.

Syntax

objAppointmentItem.Organizer

objAppointmentItem Required. An expression that returns an AppointmentItem object.


OriginalDate Property

Returns the original date and time of an AppointmentItem before it was altered. This property will return the original date even if the AppointmentItem has been deleted but it will not return the original time if deletion has occurred.

Read-only as Date/Time.

Syntax

objException.OriginalDate

objException Required. An expression that returns an Exception object.


OriginatorDeliveryReportRequested Property

Sets a Boolean value that determines whether the originator of the meeting item or mail message will receive a delivery report. Each transport provider that handles your message sends you a single delivery notification containing the names and addresses of each recipient to whom it was delivered. Note that delivery does not imply that the message has been read. The OriginatorDeliveryReportRequested property corresponds to the MAPI property PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED.

True if the originator requested a delivery receipt on the message.

Read/write Boolean.

Syntax

object.OriginatorDeliveryReportRequested

object Required. An expression that returns a MailItem or a MeetingItem object.


OtherAddress Property

Returns or sets the other address for the contact.

Read/write String.

Syntax

objContactItem.OtherAddress

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property contains the full, unparsed other address for the contact.


OtherAddressCity Property

Returns or sets the city portion of the other address for the contact.

Read/write String.

Syntax

objContactItem.OtherAddressCity

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the OtherAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to OtherAddress.


OtherAddressCountry Property

Returns or sets the country portion of the other address for the contact.

Read/write String.

Syntax

objContactItem.OtherAddressCountry

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the OtherAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to OtherAddress.


OtherAddressPostalCode Property

Returns or sets the postal code portion of the other address for the contact.

Read/write String.

Syntax

objContactItem.OtherAddressPostalCode

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the OtherAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to OtherAddress.


OtherAddressPostOfficeBox Property

Returns or sets the post office box portion of the other address for the contact.

Read/write String.

Syntax

objContactItem.OtherAddressPostOfficeBox

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the OtherAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to OtherAddress.


OtherAddressState Property

Returns or sets the state portion of the other address for the contact.

Read/write String.

Syntax

objContactItem.OtherAddressState

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the OtherAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to OtherAddress.


OtherAddressStreet Property

Returns or sets the street portion of the other address for the contact.

Read/write String.

Syntax

objContactItem.OtherAddressStreet

objContactItem Required. An expression that returns a ContactItem object.

Remarks

This property is parsed from the OtherAddress property, but may be changed or entered independently should it be parsed incorrectly. Note that any such changes or entries to this property will be overwritten by any subsequent changes or entries to OtherAddress.


OtherFaxNumber Property

Returns or sets the other fax number for the contact.

Read/write String.

Syntax

objContactItem.OtherFaxNumber

objContactItem Required. An expression that returns a ContactItem object.


OtherTelephoneNumber Property

Returns or sets the other telephone number for the contact.

Read/write String.

Syntax

objContactItem.OtherTelephoneNumber

objContactItem Required. An expression that returns a ContactItem object.


 OutlookInternalVersion Property

OutlookInternalVersion Property

Returns the build number of the Outlook application for an Outlook item.

Read-only Long.

Syntax

object.OutlookInternalVersion

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


 OutlookVersion Property

OutlookVersion Property

Returns the major and minor version number of the Outlook application for an Outlook item.

Read-only String.

Syntax

object.OutlookVersion

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


Owner Property

Returns or sets the owner for the task. This is a free-form string field. Setting this property to someone other than the current user does not have the effect of delegating the task.

Read/write String.

Syntax

objTaskItem.Owner

objTaskItem Required. An expression that returns a TaskItem object.


Ownership Property

Returns the ownership state of the task. Can be one of the following OlTaskOwnership constants: olDelegatedTask(1), olNewTask(0), or olOwnTask(2).

Read-only Long.

Syntax

objTaskItem.Ownership

objTaskItem Required. An expression that returns a TaskItem object.


PagerNumber Property

Returns or sets the pager number for the contact.

Read/write String.

Syntax

objContactItem.PagerNumber

objContactItem Required. An expression that returns a ContactItem object.


 Panes Property

Panes Property

Returns a Panes collection object representing the panes displayed by the specified explorer.

Read-only Panes.

Syntax

objExplorer.Panes

objExplorer Required. An expression that returns an Explorer object.


Parent Property

Returns the parent object of the specified object.

Read-only.

Syntax

object.Parent

object Required. An expression that returns an Outlook object.


Password Property

Returns or sets the password for modifying the form.

Read/write String.

Syntax

objFormDescription.Password

objFormDescription Required. An expression that returns a FormDescription object.


PathName Property

Returns the full path to the linked attached file. This property is only valid for linked files.

Read-only String.

Syntax

objAttachment.PathName

objAttachment Required. An expression that returns an Attachment object.


PatternEndDate Property

Returns or sets the end date for the recurrence pattern.

Read/write Date.

Syntax

objRecurrencePattern.PatternEndDate

objRecurrencePattern Required. An expression that returns a RecurrencePattern object.

Example:

Set myRecPatt = myApptItem.GetRecurrencePattern
myRecPatt.PatternEndDate = #9/13/98#

Remarks

This property is optional but must be coordinated with other properties when setting up a recurrence pattern. If this property or the Occurrences property is set, the pattern is considered to be finite, and the NoEndDate property is False. If neither PatternEndDate nor Occurrences is set, the pattern is considered infinite and NoEndDate is True. The Interval property must be set before setting PatternEndDate.


PatternStartDate Property

Returns or sets the start date for the recurrence pattern.

Read/write Date.

Syntax

objRecurrencePattern.PatternStartDate

objRecurrencePattern Required. An expression that returns a RecurrencePattern object.

Example:

Set myRecPatt = myApptItem.GetRecurrencePattern
myRecPatt.PatternStartDate = #7/20/98#


PercentComplete Property

Returns or sets the percentage of the task completed at the current date and time.

Read/write Long.

Syntax

objTaskItem.PercentComplete

objTaskItem Required. An expression that returns a TaskItem object.


PersonalHomePage Property

Returns or sets the URL of the personal Web page for the contact.

Read/write String.

Syntax

objContactItem.PersonalHomePage

objContactItem Required. An expression that returns a ContactItem object.


 Position Property

Position Property

Returns or sets the position of the attachment within the body of the item.

Read/write Long.

Syntax

objAttachment.Position

objAttachment Required. An expression that returns an Attachment object.


Prefix Property

Returns or sets the prefix (for example, "Re") to use with the subject of the item when the action is executed. Note that Outlook automatically adds a colon (:) to the value of the Prefix property when setting the subject of the item.

Read/write String.

Syntax

objAction.Prefix

objAction Required. An expression that returns an Action object.


PrimaryTelephoneNumber Property

Returns or sets the primary telephone number for the contact.

Read/write String.

Syntax

objContactItem.PrimaryTelephoneNumber

objContactItem Required. An expression that returns a ContactItem object.


ProductCode Property

Returns the Microsoft Outlook globally unique identifier (GUID).

Read-only String

Syntax

object.ProductCode()

object Required. An expression that returns an Application object.


Profession Property

Returns or sets the profession for the contact.

Read/write String.

Syntax

objContactItem.Profession

objContactItem Required. An expression that returns a ContactItem object.


RadioTelephoneNumber Property

Returns or sets the radio telephone number for the contact.

Read/write String.

Syntax

objContactItem.RadioTelephoneNumber

objContactItem Required. An expression that returns a ContactItem object.


ReadReceiptRequested Property

True if a read receipt has been requested by the sender. This property corresponds to the MAPI property PR_READ_RECEIPT_REQUESTED.

Read/write Boolean.

Syntax

objMailItem.ReadReceiptRequested

objMailItem Required. An expression that returns a MailItem object.


ReceivedByEntryID Property

Returns the EntryID for the true recipient as set by the transport provider delivering the mail message. This property corresponds to the MAPI property PR_RECEIVED_BY_ENTRYID.

Read-only String.

Syntax

objMailItem.ReceivedByEntryID

objMailItem Required. An expression that returns a MailItem object.


ReceivedByName Property

Returns display name of the true recipient for the mail message. This property corresponds to the MAPI property PR_RECEIVED_BY_NAME.

Read-only String.

Syntax

objMailItem.ReceivedByName

objMailItem Required. An expression that returns a MailItem object.


ReceivedOnBehalfOfEntryID Property

Returns the EntryID of the user delegated to represent the recipient for the mail message. This property corresponds to the MAPI property PR_RCVD_REPRESENTING_ENTRYID.

Read-only String.

Syntax

objMailItem.ReceivedOnBehalfOfEntryID

objMailItem Required. An expression that returns a MailItem object.


ReceivedOnBehalfOfName Property

Returns the display name of the user delegated to represent the recipient for the mail message. This property corresponds to the MAPI property PR_RCVD_REPRESENTING_NAME.

Read-only String.

Syntax

objMailItem.ReceivedOnBehalfOfName

objMailItem Required. An expression that returns a MailItem object.


ReceivedTime Property

Returns the date and time at which the mail message, meeting item, or post was received.

Read-only Date.

Syntax

object.ReceivedTime

object Required. An expression that returns a MailItem, MeetingItem, or PostItem object.


RecipientReassignmentProhibited Property

True if the recipient cannot forward the mail message.

Read/write Boolean.

Syntax

objMailItem.RecipientReassignmentProhibited

objMailItem Required. An expression that returns a MailItem object.


 Recipients Property

Recipients Property

Returns a Recipients collection that represents all the recipients for the Outlook item.

Read-only.

Syntax

object.Recipients

object Required. An expression that returns an AppointmentItem, JournalItem, MailItem, MeetingItem, or TaskItem object.


RecurrenceState Property

Returns the recurrence property of the object. Can be one of the following OlRecurrenceState constants: olApptException(3), olApptMaster(1), olApptNotRecurring(0), olApptOccurrence(2).

Read-only.

Syntax

objAppointmentItem.RecurrenceState

obAppointmentItem Required. An expression that returns an AppointmentItem object.


RecurrenceType Property

Returns or sets the frequency of occurrences for the recurrence pattern. Can be one of the following OlRecurrenceType constants: olRecursDaily(0), olRecursWeekly(1), olRecursMonthly(2), olRecursMonthNth(3), olRecursYearly(5), or olRecursYearNth(6). Use the Interval property to specify the number of units of a given recurrence type between occurrences in the pattern.

Read/write Long.

Syntax

objRecurrencePattern.RecurrenceType

objRecurrencePattern Required. An expression that returns a RecurrencePattern object.


ReferredBy Property

Returns or sets the referral name entry for the contact.

Read/write String.

Syntax

objContactItem.ReferredBy

objContactItem Required. An expression that returns a ContactItem object.


Regenerate Property

True if the task should be regenerated following this pass through the recurrence pattern. This property is used to control the regeneration of the task as each occurrence of a recurring task is completed.

Read/write Boolean.

Syntax

obRecurrencePattern.Regenerate

objRecurrencePattern Required. An expression that returns a RecurrencePattern object.


ReminderMinutesBeforeStart Property

Returns or sets the number of minutes the reminder should occur prior to the start of the appointment.

Read/write Long.

Syntax

objAppointmentItem.ReminderMinutesBeforeStart

objAppointmentItem Required. An expression that returns an AppointmentItem object.


ReminderOverrideDefault Property

True if the reminder overrides the default reminder behavior for the appointment, mail item, or task.

Note You must set the ReminderOverrideDefault property to validate the ReminderPlaySound and the ReminderSoundFile properties.

Read/write Boolean.

Syntax

object.ReminderOverrideDefault

object Required. An expression that returns an AppointmentItem, MailItem, or TaskItem object.


ReminderPlaySound Property

True if the reminder should play a sound when it occurs for this appointment or task.

Note This property is only valid if the ReminderOverrideDefault property is set to True.

The ReminderPlaySound property must be set in order to validate the ReminderSoundFile property.

Read/write Boolean.

Syntax

object.ReminderPlaySound

object Required. An expression that returns an AppointmentItem, MailItem, or TaskItem object.


ReminderSet Property

True if a reminder has been set for this appointment, mail item or task.

Read/write Boolean.

Syntax

object.ReminderSet

object Required. An expression that returns an AppointmentItem, MailItem, or TaskItem object.


ReminderSoundFile Property

Returns or sets the path and filename of the sound file to play when the reminder occurs for the appointment, mail message, or task. This property is only valid if the ReminderOverrideDefault and ReminderPlaySound properties are set to True.

Read/write String.

Syntax

object.ReminderSoundFile

object Required. An expression that returns an AppointmentItem, MailItem, or TaskItem object.


 ReminderTime Property

ReminderTime Property

Returns or sets the date and time at which the reminder should occur for this item.

Read/write Date.

Syntax

object.ReminderTime

object Required. An expression that returns a MailItem, MeetingItem or TaskItem object..


RemoteMessageClass Property

Returns the message class for the remote item.

Read-only String.

Syntax

objRemoteItem.RemoteMessageClass

objRemoteItem Required. An expression that returns a RemoteItem object.


RemoteStatus Property

Returns or sets the remote status of the mail message. Can be one of the following OlRemoteStatus constants: olMarkedForCopy(3), olMarkedForDelete(4), olMarkedForDownload(2), olRemoteStatusNone(0), or olUnMarked(1).

Read/write Long.

Syntax

objMailItem.RemoteStatus

objMailItem Required. An expression that returns a MailItem object.


ReplyRecipientNames Property

Returns the semicolon-delimited list of reply recipients for the mail message. This property only contains the display names for the reply recipients. The reply recipients list should be set by using the ReplyRecipients collection.

Read-only String.

Syntax

objMailItem.ReplyRecipientNames

objMailItem Required. An expression that returns a MailItem object.


ReplyRecipients Property

Returns a Recipients collection that represents all the reply recipient objects for the mail message.

Read-only Recipients.

Syntax

objMailItem.ReplyRecipients

objMailItem Required. An expression that returns a MailItem object.


ReplyStyle Property

Returns or sets the text formatting reply style for the action. Can be one of the following OlActionReplyStyle constants: olEmbedOriginalItem(1), olIncludeOriginalText(2), olIndentOriginalText(3), olLinkOriginalItem(4), olOmitOriginalText(0), olReplyTickOriginalText(1000), or olUserPreference(5).

Read/write Long.

Syntax

objAction.ReplyStyle

objAction Required. An expression that returns an Action object.


ReplyTime Property

Returns or sets the reply time for the appointment.

Read/write Date.

Syntax

objAppointmentItem.ReplyTime

objAppointmentItem Required. An expression that returns an AppointmentItem object.


 RequiredAttendees Property

RequiredAttendees Property

Returns the semicolon-delimited string of required attendee names for the meeting appointment. This property only contains the display names for the required attendees. The attendee list should be set by using the Recipients collection.

Read/write String.

Syntax

objAppointmentItem.RequiredAttendees

objAppointmentItem Required. An expression that returns an AppointmentItem object.


Resolved Property

True if the recipient has been validated against the Address Book.

Read-only Boolean.

Syntax

objRecipient.Resolved

objRecipient Required. An expression that returns a Recipient object.


 Resources Property

Resources Property

Returns the semicolon-delimited string of resource names for the meeting. This property contains the display names only. The Recipients collection should be used to modify the resource recipients. Resources are added as BCC recipients to the collection.

Read/write String.

Syntax

objAppointmentItem.Resources

objAppointmentItem Required. An expression that returns an AppointmentItem object.


ResponseRequested Property

True if the sender would like a response to the meeting request for the appointment.

Read/write Boolean.

Syntax

objAppointmentItem.ResponseRequested

objAppointmentItem Required. An expression that returns an AppointmentItem object.


ResponseState Property

Returns or sets the overall status of the response to the task request. Can be one of the following OlTaskResponse constants: olTaskAccept(2), olTaskAssign(1), olTaskDecline(3), or olTaskSimple(0).

Read-only Long.

Syntax

objTaskItem.ResponseState

objTaskItem Required. An expression that returns a TaskItem object.


ResponseStatus Property

Returns or sets the overall status of the meeting for the current user for the appointment. Can be one of the following OlResponseStatus constants: olResponseAccepted(3), olResponseDeclined(4), olResponseNone(0), olResponseNotResponded(5), olResponseOrganized(1), or olResponseTentative(2).

Read/write Long.

Syntax

objAppointmentItem.ResponseStatus

objAppointmentItem Required. An expression that returns an AppointmentItem object.


ResponseStyle Property

Returns or sets the response style used when the action is executed. Can be one of the following OlActionResponseStyle constants: olOpen(0), olPrompt(2), or olSend(1).

Read/write Long.

Syntax

objAction.ResponseStyle

objAction Required. An expression that returns an Action object.


Role Property

Returns or sets the free-form text string associating the owner of a task with a role for the task.

Read/write String.

Syntax

objTaskItem.Role

objTaskItem Required. An expression that returns a TaskItem object.


 Saved Property

Saved Property

True if the Outlook item has not been modified since the last save.

Read-only Boolean.

Syntax

object.Saved

object Required. An expression that returns an Outlook item object that is listed in the "Applies To" list.


SaveSentMessageFolder Property

Returns or sets the MAPIFolder object that represents the folder in which a copy of the mail message will be saved upon being sent.

Read/write.

Syntax

objMailItem.SaveSentMessageFolder

objMailItem Required. An expression that returns a MailItem object.


SchedulePlusPriority Property

Returns or sets the Microsoft Schedule+ priority for the task. Can be 1 through 9, A through Z, or A1 through Z9. Priority 1 is the highest.

Read/write String.

Syntax

objTaskItem.SchedulePlusPriority

objTaskItem Required. An expression that returns a TaskItem object.


ScriptText Property

Returns a string containing all the VBScript in the form's Script Editor.

Read-only String.

Syntax

objFormDescription.ScriptText

objFormDescritipn Required. An expression that returns a FormDescription object.


SelectedMailingAddress Property

Returns or sets the type of the mailing address for the contact. Can be one of the following OlMailingAddress constants: olBusiness(2), olHome(1), olNone(0), or olOther(3).

Read/write Long.

Syntax

objContactItem.SelectedMailingAddress

objContactItem Required. An expression that returns a ContactItem object.


 Selection Property

Selection Property

Returns a collection consisting of the items selected in the current view.

Read-only Items.

Syntax

objExplorer.Selection

objExplorer Required. An expression that returns an Explorer object.

Remarks

If the current folder is a file-system folder, or if Outlook Today is currently displayed, this property returns an empty collection.


SenderName Property

Returns the display name of the sender for the mail message, meeting item or post. This property corresponds to the MAPI property PR_SENDER_NAME.

Read-only String.

Syntax

object.SenderName

object Required. An expression that returns a MailItem, MeetingItem or PostItem object.


 Sensitivity Property

Sensitivity Property

Returns or sets the sensitivity for the Outlook item. Can be one of the following OlSensitivity constants: olConfidential(3), olNormal(0), olPersonal(1), or olPrivate(2). This property corresponds to the MAPI property PR_SENSITIVITY.

Read-only Long for RemoteItem and ReportItem. For all other objects, Read/write Long.

Syntax

object.Sensitivity

object Required. An expression that returns an item Outlook object that is listed in the "Applies To" list.


 Sent Property

Sent Property

Returns a Boolean value that indicates if a message has been sent. True if sent, False if not sent.

In general, there are three different kinds of messages: sent, posted, and saved. Sent messages are traditional e-mail messages or meeting items sent to a recipient or public folder. Posted messages are created in a public folder. Saved messages are created and saved without either sending or posting.

Read-only Boolean.

Syntax

object.Sent

object Required. An expression that returns a MeetingItem or MailItem object.


SentOn Property

Returns the date and time on which the mail message, meeting item, or post was sent. This property corresponds to the MAPI property PR_CLIENT_SUBMIT_TIME. When you send a meeting request item using the object's Send method, the transport provider sets the ReceivedTime and SentOn properties for you.

Read-only Date/Time.

Syntax

object.SentOn

object Required. An expression that returns a MailItem, MeetingItem or PostItem object.


SentOnBehalfOfName Property

Returns the display name for the intended sender of the mail message. This property corresponds to the MAPI property PR_SENT_REPRESENTING_NAME.

Read/write String.

Syntax

objMailItem.SentOnBehalfOfName

objMailItem Required. An expression that returns a MailItem object.


 Session Property

Session Property

Returns the NameSpace object for the current session.

Read-only.

Syntax

object.Session

object Required. An expression that returns the object to which the Session property is being applied.


 Shortcuts Property

Shortcuts Property

Returns the collection of shortcuts contained within the specified Outlook Bar group.

Read-only OutlookBarShortcuts

Syntax

objOutlookBarGroup.Shortcuts

objOutlookBarGroup Required. An expression that returns an OutlookBarGroup object.


ShowOn Property

Returns or sets the location where the action will be shown. Can be one of the following OlActionShowOn constants: olDontShow, olMenu, or olMenuAndToolbar.

Read/write Long.

Syntax

objAction.ShowOn

objAction Required. An expression that returns an Action object.


 Size Property

Size Property

Returns the size (in bytes) of the Outlook item.

Read-only Long.

Syntax

object.Size

object Required. An expression that returns an Outlook item object that is listed in the "Applies To" list.


Spouse Property

Returns or sets the spouse name entry for the contact.

Read/write String.

Syntax

objContactItem.Spouse

objContactItem Required. An expression that returns a ContactItem object.


Start Property

Returns or sets the starting date and time for the appointment or journal entry.

Read/write Date.

Syntax

object.Start

object Required. An expression that returns an AppointmentItem or JournalItem object.


StartDate Property

Returns or sets the starting date and time for the task.

Read/write Date.

Syntax

objTaskItem.StartDate

objTaskItem Required. An expression that returns a TaskItem object.


StartTime Property

Returns or sets the start time for a given occurrence of the recurrence pattern. This property is only valid for appointments.

Read/write Date.

Syntax

objRecurrencePattern.StartTime

objRecurrencePattern Required. An expression that returns a RecurrencePattern object.


Status Property

Returns or sets the status for the task. Can be one of the following OlTaskStatus constants: olTaskComplete(2), olTaskDeferred(4), olTaskInProgress(1), olTaskNotStarted(0), or olTaskWaiting(3).

Corresponds to the Status: field of a TaskItem.

Read/write Long.

Syntax

objTaskItem.Status

objTaskItem Required. An expression that returns a TaskItem object.


StatusOnCompletionRecipients Property

Returns the semicolon-delimited string of display names for recipients who will receive status upon completion of the task. This property is calculated from the Recipients property. Recipients returned by the StatusOnCompletionRecipients property correspond to BCC recipients in the Recipients collection.

Read-only String.

Syntax

objTaskItem.StatusOnCompletionRecipients

objTaskItem Required. An expression that returns a TaskItem object.


StatusUpdateRecipients Property

Returns the semicolon-delimited string of display names for recipients who receive status updates for the task. This property is calculated from the Recipients property. Recipients returned by the StatusUpdateRecipients property correspond to CC recipients in the Recipients collection.

Read-only String.

Syntax

objTaskItem.StatusUpdateRecipients

objTaskItem Required. An expression that returns a TaskItem object.


StoreID Property

Returns or sets the store ID for the folder.

Read-only String.

Syntax

objMAPIFolder.StoreID

objMAPIFolder Required. An expression that returns a MAPIFolder object.


 Subject Property

Subject Property

Returns or sets the subject for the Outlook item. This property corresponds to the MAPI property PR_SUBJECT. The Subject property is the default property for Outlook items.

Read/write String.

Note For a NoteItem object, the Subject property is a read-only string that is calculated from the body text of the note.

Syntax

object.Subject

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


 Submitted Property

Submitted Property

Returns a Boolean value that indicates if the item has been submitted. True if the item has been submitted. A message is always created and submitted in a folder, usually the Outbox.

Read-only Boolean.

Syntax

object.Submitted

object Required. An expression that returns a MeetingItem or MailItem object.


Suffix Property

Returns or sets the name suffix (such as Jr., III, or Ph.D.) for the contact.

Read/write String.

Syntax

objContactItem.Suffix

objContactItem Required. An expression that returns a ContactItem object.

Note: The LastName, FirstName, MiddleName, and Suffix properties are parsed from the FullName property.


 SyncObjects Property

SyncObjects Property

Returns the collection containing all synchronization profiles.

Read-only SyncObjects

Syntax

objNameSpace.SyncObjects

olNameSpace Required. An expression that returns a NameSpace object.


 Target Property

Target Property

Returns the target of the specified shortcut in an Outlook Bar group.

Read-only Variant

Syntax

objOutlookBarShortcut.Target

objOutlookBarShortcut Required. An expression that returns an OutlookBarShortcut object.

Remarks

The return type depends on the shortcut type. If the shortcut represents a Microsoft Outlook folder, the return type is MAPIFolder. If the shortcut represents a file-system folder, the return type is an Object. If the shortcut represents a file-system path or URL, the return type is a String,.


TeamTask Property

True if the task is a team task.

Read/write Boolean.

Syntax

objTaskItem.TeamTask

objTaskItem Required. An expression that returns a TaskItem object.


TelexNumber Property

Returns or sets the telex number for the contact.

Read/write String.

Syntax

objContactItem.TelexNumber

objContactItem Required. An expression that returns a ContactItem object.


Template Property

Returns or sets the name of the template for the form.

Note This property refers to a Microsoft Word .DOT template file, and so is applicable for forms with UseWordMail = True.

Read/write String.

Syntax

objFormDescription.Template

objFormDescription Required. An expression that returns a FormDescription object.


Title Property

Returns or sets the title for the contact.

Read/write String.

Syntax

objContactItem.Title

objContactItem Required. An expression that returns a ContactItem object.


To Property

Returns or sets the semicolon-delimited list of display names for the To recipients for the Outlook item. This property contains the display names only. The To property corresponds to the MAPI property PR_DISPLAY_TO. The Recipients collection should be used to modify this property.

Read/write String.

Syntax

objMailItem.To

objMailItem Required. An expression that returns a MailItem object.


Top Property

Returns or sets the position (in pixels) of the top horizontal edge of an explorer, inspector, or note window from the edge of the screen.

Read/write Long.

Syntax

object.Top

object Required. An expression that returns an Explorer, Inspector, or NoteItem object.


TotalWork Property

Returns or sets the total work for the task.

Corresponds to the Total work: field on the Details page of a TaskItem.

Read/write Long.

Syntax

objTaskItem.TotalWork

objTaskItem Required. An expression that returns a TaskItem object.


TrackingStatus Property

Returns or sets the tracking status for the recipient. Can be one of the following OlTrackingStatus constants: olTrackingDelivered(1), olTrackingNone(0), olTrackingNotDelivered(2), olTrackingNotRead(3), olTrackingRead(6), olTrackingRecallFailure(4), olTrackingRecallSuccess(5), or olTrackingReplied(7).

Read/write Long.

Syntax

objRecipient.TrackingStatus

objRecipient Required. An expression that returns a Recipient object.


TrackingStatusTime Property

Returns or sets the tracking status date and time for the recipient.

Read/write Date.

Syntax

objRecipient.TrackingStatusTime

objRecipient Required. An expression that returns a Recipient object.


TransferSize Property

Returns the transfer size (in bytes) for the remote item.

Read-only Long.

Syntax

objRemoteItem.TransferSize

objRemoteItem Required. An expression that returns a RemoteItem object.


TransferTime Property

Returns the transfer time (in seconds) for the remote item.

Read-only Long.

Syntax

objRemoteItem.TransferTime

objRemoteItem Required. An expression that returns a RemoteItem object.


TTYTDDTelephoneNumber Property

Returns or sets the TTY/TDD telephone number for the contact.

Read/write String.

Syntax

objContactItem.TTYTDDTelephoneNumber

objContactItem Required. An expression that returns a ContactItem object.


Type Property

Returns or sets the type of the object, as shown in the following table.

Object | Type
AddressEntry | The type of entry for this address such as an Internet Address, MacMail Address, or Microsoft Mail Address. Read/write String.
Attachment | Can be one of the following OlAttachmentType constants: olByReference(4), olByValue(1), olEmbeddedItem(5), or olOLE(6). Read-only Long.
JournalItem | A free-form string field, usually containing the display name of the journalizing application (for example, "MSWord"). Read/write String.
Link | The type of item represented by the Link object. Read-only Long.
NameSpace | The only supported type is "MAPI." Read-only String.
Recipient (of JournalItem) | The OlJournalRecipientType constant: olAssociatedContact(1). Read/write Long.
Recipient (of MailItem) | Can be one of the following OlMailRecipientType constants: olBCC(3), olCC(2), olOriginator(0), or olTo(1). Read/write Long.
Recipient (of MeetingItem) | Can be one of the following OlMeetingRecipientType constants: olOptional(2), olOrganizer(0), olRequired(1), or olResource(3). Read/write Long.
Recipient (of TaskItem) | Can be either of the following OlTaskRecipientType constants: olFinalStatus(3), or olUpdate(2). Read/write Long.
UserProperty | Can be one of the following OlUserPropertyType constants: olCombination(19), olCurrency(14), olDateTime(5), olDuration(7), olFormula(18), olKeywords(11), olNumber(3), olPercent(12), olText(1), or olYesNo(6). Read-only Long.


 UnRead Property

UnRead Property

True if the Outlook item has not been opened (read).

Read/write Boolean.

Syntax

object.UnRead

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


 UnReadItemCount Property

UnReadItemCount Property

Returns the number of unread items in the folder.

Read-only Long.

Syntax

objMAPIFolder.UnReadItemCount

objMAPIFolder Required. An expression that returns a MAPIFolder object.


User1 Property

Returns or sets the first Microsoft Schedule+ user for the contact.

Read/write String.

Syntax

objContactItem.User1

objContactItem Required. An expression that returns a ContactItem object.


User2 Property

Returns or sets the second Microsoft Schedule+ user for the contact.

Read/write String.

Syntax

objContactItem.User2

objContactItem Required. An expression that returns a ContactItem object.


User3 Property

Returns or sets the third Microsoft Schedule+ user for the contact.

Read/write String.

Syntax

objContactItem.User3

objContactItem Required. An expression that returns a ContactItem object.


User4 Property

Returns or sets the fourth Microsoft Schedule+ user for the contact.

Read/write String.

Syntax

objContactItem.User4

objContactItem Required. An expression that returns a ContactItem object.


UserCertificate Property

Returns or sets the string containing the user's authentication certificate for the contact.

Read/write String.

Syntax

objContactItem.UserCertificate

objContactItem Required. An expression that returns a ContactItem object.


 UserProperties Property

UserProperties Property

Returns the UserProperties collection that represents all the user properties for the Outlook item.

Read-only.

Syntax

object.UserProperties

object Required. An expression that returns an Outlook object that is listed in the "Applies To" list.


UseWordMail Property

True to use Microsoft Word as the default editor for the form.

Read/write Boolean.

Syntax

objFormDescription.UseWordMail

objFormDescription Required. An expression that returns a FormDescription object.


ValidationFormula Property

Returns or sets the validation formula for the user property. This property is just a descriptive string; it does not have any validation functionality.

Read/write String.

Syntax

objUserProperty.ValidationFormula

objUserProperty Required. An expression that returns a UserProperty object.


ValidationText Property

Returns or sets the validation text for the user property.

Read/write String.

Syntax

objUserProperty.ValidationText

objUserProperty Required. An expression that returns a UserProperty object.


Value Property

Returns or sets the value for the user property.

Read/write Variant.

Syntax

objUserProperty.Value

objUserProperty Required. An expression that returns a UserProperty object.


Version Property

Returns or sets the number of the version.

Read/write String.

Syntax

objFormDescription.Version

objFormDescription Required. An expression that returns an Application object or a FormDescription object.


 ViewType Property

ViewType Property

Returns or sets the icon view displayed by the specified Outlook Bar group. Can be one of the following OlOutlookBarViewtypes values: olLargeIcon(1) or olSmallIcont (2).

Read/write Long

Syntax

objOutlookBarGroup.ViewType

objOutlookBarGroup Required. An expression that returns an OutlookBarGroup object.


 Visible Property

Visible Property

Returns or sets the visible state of the Outlook Bar pane. True to display the pane, False to hide the pane.

Read/Write Boolean.

Syntax

objPane.Visible

objPane Required. An expression that returns an OutlookBarPane object

Remarks

You can also use the ShowPane method or the IsPaneVisible method of the parent Explorer object to set or retrieve this value.


VotingOptions Property

Returns or sets a delimited string containing the voting options for the mail message.

Read/write String.

Syntax

objMailItem.VotingOptions

objMailItem Required. An expression that returns a MailItem object.


VotingResponse Property

Returns or sets the voting response for the mail message. This property is usually set to one of the delimited values returned by the VotingOptions property on a reply to the original message.

Read/write String.

Syntax

objMailItem.VotingResponse

objMailItem Required. An expression that returns a MailItem object.


WebPage Property

Returns or sets the URL of the Web page for the contact.

Read/write String.

Syntax

objContactItem.WebPage

objContactItem Required. An expression that returns a ContactItem object.


WebViewAllowNavigation Property

Returns or sets the navigation mode of the Web view for a folder. True to allow navigation using Back and Forward buttons.

Read/Write Boolean.

Syntax

olMAPIFolder.WebViewAllowNavigation

olMAPIFolder Required. An expression that returns a MAPIFolder object.

Remarks

Setting this property to True causes Microsoft Outlook to display the Web page using the Microsoft Web Control. This can cause the web page to run more slowly than if this property is set to False.


WebViewOn Property

Returns or sets the Web view state for a folder. True to display the Web page specified by the WebViewURL property.

Read/Write Boolean.

Syntax

olMAPIFolder.WebViewOn

olMAPIFolder Required. An expression that returns a MAPIFolder object.

Remarks

This property is always False if WebViewURL is empty.


WebViewURL Property

Returns or sets the URL of the Web page that is assigned to a folder.

Read/Write String.

Syntax

olMAPIFolder.WebViewURL

olMAPIFolder Required. An expression that returns a MAPIFolder object.


Width Property

Returns or sets the width (in pixels) for an explorer, inspector, or note window.

Read/write Long.

Syntax

object.Width

object Required. An expression that returns an Explorer, Inspector, or NoteItem object.


WindowState Property

Returns or sets the window state of an explorer or inspector window. Can be any of the following OlWindowState values: olMaximized(1), olMinimized(2), or olNormal(3).

Read/write Long.

Syntax

object.WindowState

object Required. An expression that returns an Explorer or Inspector object.


WordEditor Property

Returns the Word Document Object Model of the message being displayed. This object model may be temporary and should not be stored for later use. The WordEditor property is only valid if IsWordMail returns True and the EditorType is olEditorWord(4).

Read-only.

Syntax

objInspector.WordEditor

objInspector Required. An expression that returns an Inspector object.


YomiCompanyName Property

Returns or sets the Japanese phonetic rendering (yomigana) of the company name for the contact.

Read/write String.

Syntax

objContactItem.YomiCompanyName

objContactItem Required. An expression that returns a ContactItem object.


YomiFirstName Property

Returns or sets the Japanese phonetic rendering (yomigana) of the first name for the contact.

Read/write String.

Syntax

objContactItem.YomiFirstName

objContactItem Required. An expression that returns a ContactItem object.


YomiLastName Property

Returns or sets the Japanese phonetic rendering (yomigana) of the last name for the contact.

Read/write String.

Syntax

objContactItem.YomiLastName

objContactItem Required. An expression that returns a ContactItem object.


 Step 2: Create an Outlook item in a public folder

Step 2: Create an Outlook item in a public folder

  1. If the public folder, that you want to use does not exist, you can create it.

    How?

  2. In the Folder List or on the Outlook Bar, select the public folder in which you want to add the new item.

  3. On the File menu, point to New, and then click the item that you want to create.

Tip To quickly let others add the public folder to their Public Folders folder, you can send a shortcut in a mail message.

To go on to Step 3, click [image] .


 Step 1: Create a public folder

Step 1: Create a public folder

To create a public folder, you must have permission to create folders in an existing public folder. For information about how to obtain permission, see your administrator.

  1. On the File menu, select New, and then click Folder. (CTRL+SHIFT+E)

  2. In the Name box, enter a name for the folder.

  3. In the Folder contains box, click the type of item that you want the folder to contain. A folder can only contain one type of item.

  4. In the Select where to place the folder box, click the public folder in which you want your new public folder to appear.

  5. If you do not want to add a Shortcut for the public folder to your Outlook Bar, click No in the Add shortcut to Outlook Bar? box.

Note You can copy a private folder to a public folder for quick creation of a public folder with existing items.

To go on to Step 2, click


Context Property

This property returns an empty string in Microsoft Outlook and is not supported in any other way.


Controls Collection

Includes all the controls contained in an object.

Remarks

Each control in a Controls collection has a unique index whose value can be either an integer or a string. The index value for the first control in a collection is 0; the value for the second control is 1; and so on. This value indicates the order in which the controls were added to the collection.

If the index is a string, it represents the name of the control. The Name property of a control also specifies the control’s name.

You can use the Controls collection to enumerate or count individual controls and to set their properties. For example, you can enumerate the Controls collection of a page and set the Height property of each control to a specified value.

Note The For Each...Next loop is useful for enumerating a collection.


Pages Collection

A Pages collection includes all the pages of a MultiPage.

Remarks

Each Pages collection provides the features to manage the number of pages in the collection and to identify the page that is currently in use.

The default value of the Pages collection identifies the current Page of a collection.

You can reference a Page by its index value. The index value reflects the ordinal position of the Page within the collection. The index of the first Page in a collection is 0; the index of the second Page is 1; and so on.


Tabs Collection

A Tabs collection includes all Tabs of a TabStrip.

Remarks

Each Tabs collection provides the features to manage the number of tabs in the collection and to identify the tab that is currently in use.

The default value of the Tabs collection identifies the current Tab of a collection.

You can reference a Tab by its index value. The index value reflects the ordinal position of the Tab within the collection. The index of the first Tab in a collection is 0; the index of the second Tab is 1; and so on.


Automating Office forms from VBScript

Microsoft Outlook uses the Office form to display Microsoft Office documents posted to a folder or sent to a user. You cannot change the pages and controls displayed on the form, but you can add VBScript code to the form.

You can use the GetObject statement in VBScript to access an embedded Office document in an Outlook Office form.

The following sample VBScript code inserts "This is from VBScript!" into the embedded Microsoft Word document in a Microsoft Word Office form. Because the code is in the Open event procedure, the code runs automatically when the item opens. You can expand on this simple example to provide more useful results, such as inserting a formatted list of appointments.

Sub Item_Open()
   Set objWord = GetObject(, "Word.Application")
   ' Use Word methods to insert some sample text
   objWord.Selection.TypeText "This is from VBScript!"
End Sub


Form file formats

Microsoft Outlook supports forms stored using four file formats.

The Outlook Form Template (.oft) format is commonly used to back up a form while it’s being designed, or to move a form from one computer to another without publishing it. You can use the CreateItemFromTemplate method to open this form file in a program.

The message (.msg) format is often used to save mail messages or other items as files.

The CFG and FDM formats are associated with forms created for the Microsoft Exchange Client. When used in Corporate Workgroup mode, Outlook can install these forms using the Manage Forms dialog. Outlook supports these forms for backward compatibility only; you cannot modify these forms using Outlook.


Using events with Automation

To create an event handler for Microsoft Outlook objects in Microsoft Visual Basic or Microsoft Visual Basic for Applications in another application, you need to complete the following four steps:

  1. Set a reference to the Microsoft Outlook 9.0 Object Library.

  2. Declare an object variable to respond to the events.

  3. Write the specific event procedures.

  4. Initialize the declared object.

Learn about working with events in Outlook Visual Basic for Applications.

Set the Reference to the Outlook 9.0 Object Library

Before you can use an Outlook object in Visual Basic or Visual Basic for Applications code, you must first set a reference to the Outlook 9.0 Object Model in the References dialog box. For more information about using this dialog box, see the online Help for your programming environment.

Declare the Object Variable

Once you’ve referenced the object model library, you must declare variables that reference the object you want to use. You can declare the variable in the module in which the object will be used (that is, the module containing the event-handler procedure), but more commonly you’ ll declare it in a class module so it can be used in any module in your program.

For example, to declare an object variable for the Application object in a class module, you use code like the following.

Public WithEvents myOlApp As Outlook.Application

You must use the WithEvents keyword to specify that the object variable will be used to respond to events triggered by the object.

Write the Event Procedure

After the new object has been declared with events, it appears in the Object list in the class module Code window, and you can select the object’s event procedures from the Procedures/Events list. For example, when you select the ItemSend event for an Application object declared as myOlApp, the following empty procedure appears in the Code window.

Private Sub myOlApp_ItemSend(Item as Object, Cancel as Boolean)

End Sub

Initialize the Declared Object

Before the procedure will run, you must connect the declared object (in this example, myOlApp) with the Application object. If you declared the object in a class module named EventClassModule, then you can use the following code in any module.

Dim myClass as New EventClassModule

Sub Register_Event_Handler()

    Set myClass.myOlApp = CreateObject("Outlook.Application")

End Sub

When the Register_Event_Handler procedure is run, the myOlApp object in the form or class module points to the Outlook Application object, and the event procedure will run when the event occurs.


Working with EntryIDs and StoreIDs

If you’re creating a more complex solution using Microsoft Outlook that involves linking or cross-referencing items in folders, one option is to use the MAPI-based identifiers (IDs) of each item. If you know the IDs of an item and the folder it's stored in, you can directly reference the item using the GetItemFromID method.

Each Outlook item has a field called EntryID, which is a unique ID field generated by the messaging storage system for use with the MAPI folders that store the item. It’s important to note that whenever an item is created in a folder, it’s assigned a new EntryID. This means that the EntryID field changes if an item is moved to a different folder or if an item is exported and then imported (even to the same folder).

Each folder has an ID field called StoreID, the value of which is the same for all the folders in a particular message store. Each folder also has a unique EntryID field.

When using the GetItemFromID method to retrieve an item based on its IDs, you should specify both the EntryID of the item and the StoreID of the folder. If you do not specify the StoreID, GetItemFromID searches the default message store.

The following Microsoft Visual Basic/Visual Basic for Applications example illustrates the use of the GetItemFromID method. The code retrieves the StoreID from the default Contacts folder, fills an array (MyEntryID) with the EntryIDs of all of the contacts in the folder, and finally retrieves a specific contact item.

Sub OutlookEntryID()
   Dim ol As Outlook.Application
   ' If there are more than 500 contacts, change the following line:
   Dim MyEntryID(500) As String
   Dim StoreID As String
   Dim EntryID As String
   Set ol = New Outlook.Application
   Set olns = ol.GetNamespace("MAPI")
   Set objFolder = olns.GetDefaultFolder(olFolderContacts)
   ' Get the StoreID, which is a property of the folder.
   StoreID = objFolder.StoreID
   ' Set objAllContacts equal to the collection of all contacts.
   Set AllContacts = objFolder.Items
   I = 0
   ' Loop to get all of the EntryIDs for the contacts.
   For Each Item In AllContacts
      I = I + 1
      MyEntryID(I) = Item.EntryID
   Next
   ' Randomly choose the 2nd contact to retrieve..
   Set Item = olns.GetItemFromID(MyEntryID(2), StoreID)
   Item.Display
End Sub


OlActionCopyLike Constants

Constant | Value
olReply | 0
olReplyAll | 1
olForward | 2
olReplyFolder | 3
olRespond | 4


OlActionReplyStyle Constants

Constant | Value
olEmbedOriginalItem | 1
olIncludeOriginalText | 2
olIndentOriginalText | 3
olLinkOriginalItem | 4
olOmitOriginalText | 0
olReplyTickOriginalText | 1000
olUserPreference | 5


OlActionResponseStyle Constants

Constant | Value
olOpen | 0
olPrompt | 2
olSend | 1


OlActionShowOn Constants

Constant | Value
olDontShow | 0
olMenu | 1
olMenuAndToolbar | 2


OlAttachmentType Constants

Constant | Value
olByReference | 4
olByValue | 1
olEmbeddedItem | 5
olOLE | 6


OlBusyStatus Constants

Constant | Value
olBusy | 2
olFree | 0
olOutOfOffice | 3
olTentative | 1


OlDaysOfWeek Constants

Constant | Value
olFriday | 32
olMonday | 2
olSaturday | 64
olSunday | 1
olThursday | 16
olTuesday | 4
olWednesday | 8


OlDefaultFolders Constants

Constant | Value
olFolderCalendar | 9
olFolderContacts | 10
olFolderDeletedItems | 3
olFolderDrafts | 16
olFolderInbox | 6
olFolderJournal | 11
olFolderNotes | 12
olFolderOutbox | 4
olFolderSentMail | 5
olFolderTasks | 13


OlDisplayType Constants

Constant | Value
olAgent | 3
olDistList | 1
olForum | 2
olOrganization | 4
olPrivateDistList | 5
olRemoteUser | 6
olUser | 0


OlEditorType Constants

Constant | Value
olEditorHTML | 2
olEditorRTF | 3
olEditorText | 1
olEditorWord | 4


OlFlagStatus Constants

Constant | Value
olFlagComplete | 1
olFlagMarked | 2
olNoFlag | 0


OlFolderDisplayMode Constants

Constant | Value
olFolderDisplayFolderOnly | 1
olFolderDisplayNoNavigation | 2
olFolderDisplayNormal | 0


OlFormRegistry Constants

Constant | Value
olDefaultRegistry | 0
olFolderRegistry | 3
olOrganizationRegistry | 4
olPersonalRegistry | 2


OlGender Constants

Constant | Value
olFemale | 1
olMale | 2
olUnspecified | 0


OlImportance Constants

Constant | Value
olImportanceHigh | 2
olImportanceLow | 0
olImportanceNormal | 1


OlInspectorClose Constants

Constant | Value
olDiscard | 1
olPromptForSave | 2
olSave | 0


OlItemType Constants

Constant | Value
olAppointmentItem | 1
olContactItem | 2
olDistributionListItem | 7
olJournalItem | 4
olMailItem | 0
olNoteItem | 5
olPostItem | 6
olTaskItem | 3


OlJournalRecipientType Constants

Constant | Value
olAssociatedContact | 1


OlMailingAddress Constants

Constant | Value
olBusiness | 2
olHome | 1
olNone | 0
olOther | 3


OlMailRecipientType Constants

Constant | Value
olBCC | 3
olCC | 2
olOriginator | 0
olTo | 1


OlMeetingRecipientType Constants

Constant | Value
olOptional | 2
olOrganizer | 0
olRequired | 1
olResource | 3


OlMeetingResponse Constants

Constant | Value
olMeetingAccepted | 3
olMeetingDeclined | 4
olMeetingTentative | 2


OlMeetingStatus Constants

Constant | Value
olMeeting | 1
olMeetingCanceled | 5
olMeetingReceived | 3
olNonMeeting | 0


OlNetMeetingType Constants

Constant | Value
olChat | 2
olNetMeeting | 0
olNetShow | 1


OlNoteColor Constants

Constant | Value
olBlue | 0
olGreen | 1
olPink | 2
olWhite | 4
olYellow | 3


OlObjectClass Constants

Constant | Value
olAction | 32
olActions | 33
olAddressEntries | 21
olAddressEntry | 8
olAddressList | 7
olAddressLists | 20
olApplication | 0
olAppointment | 26
olAttachment | 5
olAttachments | 18
olContact | 40
olDistributionList | 69
olDocument | 41
olException | 30
olExceptions | 29
olExplorer | 34
olExplorers | 60
olFolder | 2
olFolders | 15
olFormDescription | 37
olInspector | 35
olInspectors | 61
olItems | 16
olJournal | 42
olLink | 75
olLinks | 76
olMail | 43
olMeetingCancellation | 54
olMeetingRequest | 53
olMeetingResponseNegative | 55
olMeetingResponsePositive | 56
olMeetingResponseTentative | 57
olNamespace | 1
olNote | 44
olOutlookBarGroup | 66
olOutlookBarGroups | 65
olOutlookBarPane | 63
olOutlookBarShortcut | 68
olOutlookBarShortcuts | 67
olOutlookBarStorage | 64
olOutlookPropertyPageSite | 70
olPages | 36
olPanes | 62
olPost | 45
olPropertyPages | 71
olRecipient | 4
olRecipients | 17
olRecurrencePattern | 28
olRemote | 47
olReport | 46
olSelection | 74
olSyncObject | 72
olSyncObjects | 73
olTask | 48
olTaskRequest | 49
olTaskRequestAccept | 51
olTaskRequestDecline | 52
olTaskRequestUpdate | 50
olUserProperties | 38
olUserProperty | 39


OlOutlookBarViewType Constants

Constant | Value
olLargeIcon | 0
olSmallIcon | 1


OlPane Constants

Constant | Value
olOutlookBar | 1
olFolderList | 2
olPreview | 3


OlRecurrenceState Constants

Constant | Value
olApptException | 3
olApptMaster | 1
olApptNotRecurring | 0
olApptOccurrence | 2


OlRecurrenceType Constants

Constant | Value
olRecursDaily | 0
olRecursMonthly | 2
olRecursMonthNth | 3
olRecursWeekly | 1
olRecursYearly | 5
olRecursYearNth | 6


OlRemoteStatus Constants

Constant | Value
olMarkedForCopy | 3
olMarkedForDelete | 4
olMarkedForDownload | 2
olRemoteStatusNone | 0
olUnMarked | 1


OlResponseStatus Constants

Constant | Value
olResponseAccepted | 3
olResponseDeclined | 4
olResponseNone | 0
olResponseNotResponded | 5
olResponseOrganized | 1
olResponseTentative | 2


OlSaveAsType Constants

Constant | Value
olDoc | 4
olHTML | 5
olMSG | 3
olRTF | 1
olTemplate | 2
olTXT | 0
olVCal | 7
olVCard | 6


OlSensitivity Constants

Constant | Value
olConfidential | 3
olNormal | 0
olPersonal | 1
olPrivate | 2


OlSortOrder Constants

Constant | Value
olAscending | 1
olDescending | 2
olSortNone | 0


OlSyncState Constants

Constant | Value
olSyncStarted | 1
olSyncStopped | 0


OlTaskDelegationStatus Constants

Constant | Value
olTaskDelegationAccepted | 2
olTaskDelegationDeclined | 3
olTaskDelegationUnknown | 1
olTaskNotDelegated | 0


OlTaskOwnership Constants

Constant | Value
olDelegatedTask | 1
olNewTask | 0
olOwnTask | 2


OlTaskRecipientType Constants

Constant | Value
olFinalStatus | 3
olUpdate | 2


OlTaskResponse Constants

Constant | Value
olTaskAccept | 2
olTaskAssign | 1
olTaskDecline | 3
olTaskSimple | 0


OlTaskStatus Constants

Constant | Value
olTaskComplete | 2
olTaskDeferred | 4
olTaskInProgress | 1
olTaskNotStarted | 0
olTaskWaiting | 3


OlTrackingStatus Constants

Constant | Value
olTrackingDelivered | 1
olTrackingNone | 0
olTrackingNotDelivered | 2
olTrackingNotRead | 3
olTrackingRead | 6
olTrackingRecallFailure | 4
olTrackingRecallSuccess | 5
olTrackingReplied | 7


OlUserPropertyType Constants

Constant | Value
olCombination | 19
olCurrency | 14
olDateTime | 5
olDuration | 7
olFormula | 18
olKeywords | 11
olNumber | 3
olPercent | 12
olText | 1
olYesNo | 6


OlWindowState Constants

Constant | Value
olMaximized | 0
olMinimized | 1
olNormal | 2


 Standard fields in a Distribution List item

Standard fields in a Distribution List item

Field

Edit in view |  | Data type and meaning
Categories | Yes | Text. Field used to group and find related items. Multiple categories are separated by commas.
Distribution List Name | Yes | Text. The name of the distribution list.
Icon | Yes | Internal Data Type.
In Folder | No | Text. Name of the folder that contains the distribution list item.
Message Class | No | Specifies the message class for the type of item. For information about the standard Outlook message classes, click
Modified | No | Date/Time. Last time the distribution list item was modified.
Outlook Internal Version | No | For administrator use only
Outlook Version | No | Text. Version of Outlook that the distribution list item is created in.
Sensitivity | No | The following settings apply. 0 Normal 1 Personal 2 Private 3 Confidential
Size | No | Number. Number of bytes used by the distribution list item.


Item Events

The following events are generated by all Outlook item objects except the NoteItem object.

AttachmentAdd

AttachmentRead

BeforeAttachmentSave

BeforeCheckNames

Close Event

CustomAction

CustomPropertyChange

Forward

Open

PropertyChange

Read

Reply

ReplyAll

Send

Write


Activate Event Example

This code example uses the WindowState property to maximize the topmost explorer window when the Activate event occurs. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As Outlook.Application
Public WithEvents myOlExp As Outlook.Explorer

Public Sub Initialize_handler()
    Set myOlExp = myOlApp.ActiveExplorer
End Sub

Private Sub myOlExp_Activate()
    If myOlExp.WindowState = olNormalWindow Then _
        myOlExp.WindowState = olMaximized
End Sub


AttachmentAdd Event Example

This VBScript example checks the size of the item after an embedded attachment has been added and displays a warning if the size exceeds 500,000 bytes.

Sub Item_AttachmentAdd(ByVal NewAttachment)
    If NewAttachment.Type = 1 Then
        Item.Save
        If Item.Size > 500000 Then
            MsgBox "Warning: Item size is now " & Item.Size & " bytes."
        End If
    End If
End Sub


AttachmentRead Event Example

This VBScript example reminds the user to also save changes to the original of an embedded file.

Sub Item_AttachmentRead(ByVal ReadAttachment)
    If ReadAttachment.Type = 1 then
        MsgBox "If you change this file, save your changes to the original as well."
    End If
End Sub


BeforeAttachmentSave Event Example

This VBScript example notifies the user that the user is not allowed to save the attachment. It returns False to cancel the save operation.

Function Item_BeforeAttachmentSave(ByVal SaveAttachment)
    MsgBox "You are not allowed to save " & SaveAttachment.Name
    Item_BeforeAttachmentSave = False
End Function


BeforeCheckNames Event Example

This VBScript example asks the user if the user wants to resolve names and returns False to cancel the operation if the user answers no.

Function Item_BeforeCheckNames()
    If MsgBox ("Do you want to resolve names now?",4) = 7 Then
        Item_BeforeCheckNames = False
    End If
End Function


BeforeFolderSwitch Event Example

This sample prevents a user from switching to a folder named Off Limits. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As Outlook.Application
Public WithEvents myOlExp As Outlook.Explorer

Public Sub Initialize_handler()
    Set myOlExp = myOlApp.ActiveExplorer
End Sub

Private Sub myOlExp_BeforeFolderSwitch(ByVal NewFolder As Object, Cancel As Boolean)
    If NewFolder.Name = "Off Limits" Then
        MsgBox "You do not have permission to access this folder."
        Cancel = True
    End If
End Sub


BeforeGroupAdd Event Example

This example prevents the user from adding a group to the Outlook Bar. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Dim WithEvents myOlGroups As Outlook.OutlookBarGroups
Dim myOlBar As Outlook.OutlookBarPane

Sub Initialize_handler()
    Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
    Set myOlGroups = myOlBar.Contents.Groups
End Sub

Private Sub myOlGroups_BeforeGroupAdd(Cancel As Boolean)
    Cancel = True
End Sub


BeforeGroupRemove Event Example

This example prevents the user from removing a group from the Outlook Bar. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Dim WithEvents myOlGroups As Outlook.OutlookBarGroups
Dim myOlBar As Outlook.OutlookBarPane

Sub Initialize_handler()
    Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
    Set myOlGroups = myOlBar.Contents.Groups
End Sub

Private Sub myOlGroups_BeforeGroupRemove(Cancel As Boolean)
    Cancel = True
End Sub


BeforeGroupSwitch Event Example

This example prevents the user from opening the Outlook Bar group named Other Shortcuts. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Public WithEvents myOlPane As Outlook.OutlookBarPane

Public Sub Initialize_handler()
    Set myOlPane = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
End Sub

Private Sub myOlPane_BeforeGroupSwitch(ByVal ToGroup As Outlook.OutlookBarGroup, Cancel As Boolean)
    If ToGroup.Name = "Other Shortcuts" Then Cancel = True
End Sub


BeforeNavigate Event Example

This example prevents the user from using the Outlook Bar to open the Notes folder. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Public WithEvents myOlPane As Outlook.OutlookBarPane

Public Sub Initialize_handler()
    Set myOlPane = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
End Sub
Private Sub myOlPane_BeforeNavigate(ByVal Shortcut As Outlook.OutlookBarShortcut, Cancel As Boolean)
    If Shortcut.Name = "Notes" Then
        MsgBox "You cannot view the Notes folder."
        Cancel = True
    End If
End Sub


BeforeShortcutAdd Event Example

The following example prevents a user from adding a shortcut to the first Outlook Bar group. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Dim WithEvents myOlShortcuts As Outlook.OutlookBarShortcuts
Dim myOlBar As Outlook.OutlookBarPane

Sub Initialize_handler()
    Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
    Set myOlShortcuts = myOlBar.Contents.Groups.Item(1).Shortcuts
End Sub

Private Sub myOlShortcuts_BeforeShortcutAdd(Cancel As Boolean)
    MsgBox "You are not allowed to add a shortcut to this group."
    Cancel = True
End Sub


BeforeShortcutRemove Event Example

The following example prevents a user from removing a shortcut from the first Outlook Bar group. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Dim WithEvents myOlShortcuts As Outlook.OutlookBarShortcuts
Dim myOlBar As Outlook.OutlookBarPane

Sub Initialize_handler()
    Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
    Set myOlShortcuts = myOlBar.Contents.Groups.Item(1).Shortcuts
End Sub

Private Sub myOlShortcuts_BeforeShortcutRemove(Cancel As Boolean)
    MsgBox "You are not allowed to remove a shortcut from this group."
    Cancel = True
End Sub


BeforeViewSwitch Event Example

This example confirms that the user wants to switch views and cancels the switch if the user answers no. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As Outlook.Application
Public WithEvents myOlExp As Outlook.Explorer

Public Sub Initialize_handler()
    Set myOlExp = myOlApp.ActiveExplorer
End Sub

Private Sub myOlExp_BeforeViewSwitch(ByVal NewView As Variant, Cancel As Boolean)
    Dim Prompt As String
    Prompt = "Are you sure you want to switch to the " & NewView & " view?"
    If MsgBox(Prompt, vbYesNo + vbQuestion) = vbNo Then Cancel = True
End Sub


 Close Event Example

Close Event Example

This example tests for the Close event and if the item has not been Saved, it uses the Save method to save the item without prompting the user.

Function Item_Close()
    If not Item.Saved Then
        Item.Save
    End If
End Function


CustomAction Event Example

This example uses the CustomAction event to set a property on the response item.

Function Item_CustomAction(ByVal myAction, ByVal myResponse)
    Select Case myAction.Name
        Case "Action1"
            myResponse.Subject = "Changed by VB Script"
        Case Else
    End Select
End Function


 CustomPropertyChange Event Example

CustomPropertyChange Event Example

This VBScript example uses the CustomPropertyChange event to enable a control when a Boolean field is set to True.

For this example, create two custom fields on the second page of a form. The first, a Boolean field, is named "RespondBy". The second field is named "DateToRespond".

Learn more about creating new fields.

Sub Item_CustomPropertyChange(ByVal myPropName)
    Select Case myPropName
        Case "RespondBy"
            Set myPages = Item.GetInspector.ModifiedFormPages
            Set myCtrl = myPages("P.2").Controls("DateToRespond")
            If Item.UserProperties("RespondBy").Value Then
                myCtrl.Enabled = True
                myCtrl.Backcolor = 65535	'Yellow
            Else
                myCtrl.Enabled = False
                myCtrl.Backcolor = 0	'Black
            End If
        Case Else
    End Select
End Sub


Deactivate Event Example

This example uses the WindowState property to minimize the topmost explorer window when it is not active. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As Outlook.Application
Public WithEvents myOlExp As Outlook.Explorer

Public Sub Initialize_handler()
    Set myOlExp = myOlApp.ActiveExplorer
End Sub

Private Sub myOlExp_Deactivate()
    myOlExp.WindowState = olMinimized
End Sub


FolderAdd Event Example

This example displays a new folder created in the user’s Inbox folder.

Dim myOlApp As New Outlook.Application
Public WithEvents myOlFolders As Outlook.Folders

Public Sub Initialize_handler()
    Set myOlFolders = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders
End Sub

Private Sub myOlFolders_FolderAdd(ByVal Folder As Outlook.MAPIFolder)
    Folder.Display
End Sub


FolderChange Event Example

This example prompts the user to remove a folder from the Deleted Items folder if the folder is empty. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myolapp As New Outlook.Application
Dim WithEvents myFolders As Outlook.Folders

Sub Initialize_handler()
    Set myNS = myolapp.GetNamespace("MAPI")
    Set myFolders = myNS.GetDefaultFolder(olFolderDeletedItems).Folders
End Sub

Private Sub myFolders_FolderChange(ByVal Folder As Outlook.MAPIFolder)
    If Folder.Items.Count = 0 Then
        MyPrompt = Folder.Name & " is empty. Do you want to delete it?"
        If MsgBox(MyPrompt, vbYesNo + vbQuestion) = vbYes Then
            Folder.Delete
        End If
    End If
End Sub


FolderRemove Event Example

This example fills a combo box on a form with the names of the folders in the Deleted Items folder. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myolapp As New Outlook.Application
Dim WithEvents myFolders As Outlook.Folders

Sub Initialize_handler()
    Set myNS = myolapp.GetNamespace("MAPI")
    Set myFolders = myNS.GetDefaultFolder(olFolderDeletedItems).Folders
End Sub

Private Sub myFolders_FolderRemove()
    Form1.Combo1.Clear
    For x = 1 To myFolders.Count
        Form1.Combo1.AddItem (myFolders.Item(x).Name)
    Next x
End Sub


FolderSwitch Event Example

This example shows or hides a menu bar, depending on the folder that is visible. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As Outlook.Application
Public WithEvents myOlExp As Outlook.Explorer

Public Sub Initialize_handler()
    Set myOlExp = myOlApp.ActiveExplorer
End Sub

Private Sub myOlExp_FolderSwitch()
    Select Case MyOlExp.CurrentFolder.Name
        Case "Sales Contacts"
            MyToolsMenu.Visible = True
        Case Else
            MyToolsMenu.Visible = False
    End Select
End Sub


 Forward Event Example

Forward Event Example

This example uses the Forward event to disable forwarding on an item by setting the return value to False and displays a message that the item may not be forwarded.

Function Item_Forward(ByVal myForwardItem)
    MsgBox "You may not forward this message!"
    Item_Forward = False
End Function


GroupAdd Event Example

This example adds a shortcut to a group when the group is created. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Dim WithEvents myOlGroups As Outlook.OutlookBarGroups
Dim myOlBar As Outlook.OutlookBarPane

Sub Initialize_handler()
    Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
    Set myOlGroups = myOlBar.Contents.Groups
End Sub

Private Sub myOlGroups_GroupAdd(ByVal NewGroup As Outlook.OutlookBarGroup)
    Dim myFolder As Outlook.MAPIFolder
    Set myFolder = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar)
    NewGroup.Shortcuts.Add myFolder, "Calendar"
End Sub


ItemAdd Event Example

In this example, when a new contact is added to the Contacts folder, the contact item is attached to a mail message and sent to a distribution list named Sales Team. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As Outlook.Application
Public WithEvents myOlItems As Outlook.Items

Public Sub Initialize_handler()
    Set myOlItems = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items
End Sub

Private Sub myOlItems_ItemAdd(ByVal Item As Object)
    Dim myOlMItem As Outlook.MailItem
    Dim myOlAtts As Outlook.Attachments
    Set myOlMItem = myOlApp.CreateItem(olMailItem)
    myOlMItem.Save
    Set myOlAtts = myOlMItem.Attachments
    ' Add new contact to attachments in mail message
    myOlAtts.Add Item, olByValue
    myOlMItem.To = "Sales Team"
    myOlMItem.Subject = "New contact"
    myOlMItem.Send
End Sub


ItemChange Event Example

This example uses the Start property of the AppointmentItem object to determine if the appointment starts after normal business hours. If it does, and if the Sensitivity property of the AppointmentItem object is not already set to olPrivate, the example offers to mark the appointment as private.

Dim myOlApp As New Outlook.Application
Public WithEvents myOlItems As Outlook.Items

Public Sub Initialize_handler()
    Set myOlItems = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar).Items
End Sub

Private Sub myOlItems_ItemChange(ByVal Item As Object)
    If Format(Item.Start, "h") >= "17" And Item.Sensitivity <> olPrivate Then
        Prompt = "Appointment occurs after hours. Mark it private?"
        If MsgBox(Prompt, vbYesNo + vbQuestion) = vbYes Then
            Item.Sensitivity = olPrivate
            Item.Display
        End If
    End If
End Sub


ItemRemove Event Example

This example optionally sends a notification message to a workgroup when the user removes a contact from the default Contacts folder. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As Outlook.Application
Public WithEvents myOlItems As Outlook.Items

Public Sub Initialize_handler()
    Set myOlItems = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts).Items
End Sub

Private Sub myOlItems_ItemRemove()
    Dim myOlMItem As Outlook.MailItem
    If MsgBox("Do you want to notify the Sales Team?", vbYesNo + vbQuestion) = vbYes Then
        Set myOlMItem = myOlApp.CreateItem(olMailItem)
        myOlMItem.To = "Sales Team"
        myOlMItem.Subject = "Remove Contact"
        myOlMItem.Body = "Please remove the following contact from your list:"
        myOlMItem.Display
    End If
End Sub


ItemSend Event Example

The following example shows how to cancel the ItemSend event in response to user input.

Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Prompt$ = "Are you sure you want to send " & Item.Subject & "?"
    If MsgBox(Prompt$, vbYesNo + vbQuestion, "Sample") = vbNo Then
        Cancel = True
    End If
End Sub


NewExplorer Event Example

This example minimizes the currently active explorer window when a new explorer is about to appear. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Public WithEvents myOlExplorers As Outlook.Explorers

Public Sub Initialize_handler()
    Set myOlExplorers = myOlApp.Explorers
End Sub

Private Sub myOlExplorers_NewExplorer(ByVal Explorer As Outlook.Explorer)
    If TypeName(myOlApp.ActiveExplorer) <> "Nothing" Then
        myOlApp.ActiveExplorer.WindowState = olMinimized
    End If
End Sub


NewInspector Event Example

This example displays the Standard and Formatting toolbars of an inspector when it is opened. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Public WithEvents myOlInspectors As Outlook.Inspectors

Public Sub Initialize_handler()
    Set myOlInspectors = myOlApp.Inspectors
End Sub

Private Sub myOlInspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
    Inspector.CommandBars.Item("Standard").Visible = True
    Inspector.CommandBars.Item("Formatting").Visible = True
End Sub


NewMail Event Example

This example displays the Inbox folder when new mail arrives. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim WithEvents myOlApp As Outlook.Application

Sub Initialize_handler()
    Set myOlApp = CreateObject("Outlook.application")
End Sub

Private Sub myOlApp_NewMail()
    Dim myExplorers As Outlook.Explorers
    Dim myFolder As Outlook.MAPIFolder
    Set myExplorers = myOlApp.Explorers
    Set myFolder = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    If myExplorers.Count <> 0 Then
        For x = 1 To myExplorers.Count
            On Error GoTo skipif
            If myExplorers.Item(x).CurrentFolder.Name = "Inbox" Then
                myExplorers.Item(x).Display
                myExplorers.Item(x).Activate
                Exit Sub
            End If
skipif:
        Next x
     End If
     On Error GoTo 0
     myFolder.Display
End Sub


OnError Event Example

This example displays a message box describing the synchronization error and sets attributes of controls on a form. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Dim WithEvents mySync As Outlook.SyncObject
Dim myForm As New Form1

Sub Initialize_handler()
    Set mySync = myOlApp.Session.SyncObjects.Item(1)
End Sub

Private Sub mySync_OnError(ByVal Code As Long, ByVal Description As String)
    Form1.Label1.Caption = "Synchronization failed."
    mySync.Stop
    Form1.Command1.Enabled = False
    Form1.Command2.Enabled = False
    MsgBox "Unexpected sync error" & Str(Code) & ": " & Description
End Sub


 Open Event Example

Open Event Example

This VBScript example uses the Open event to display the "All Fields" page every time the item is opened.

Function Item_Open()
    Item.GetInspector.SetCurrentFormPage "All Fields"
End Function

This VBScript example uses the Unread property to detect whether the item has been previously read. If it has, then it asks if the user wants to open it. If the user answers No, the return value is set to False to prevent the item from opening.

Function Item_Open()
    If Item.Unread = False Then
        myMsg = "Do you want to open this message again?"
        If MsgBox myMsg,4) = 6 Then
            Item_Open = True
        Else
            Item_Open = False
        End If
    End If
End Function


OptionsPagesAdd Event Example

This example adds a new property page to the Microsoft Outlook Options dialog box. The sample code must be placed in a class module of a Common Object Model (COM) add-in.

Implements IDTExtensibility2
Private WithEvents OutlApp As Outlook.Application

Private Sub IDTExtensibility2_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
    Set OutlApp = Application
End Sub

Private Sub OutlApp_OptionsPagesAdd(ByVal Pages As Outlook.PropertyPages)
    Dim myPage As Object
    Set myPage = CreateObject("PPE.CustomPage")
    Pages.Add myPage
End Sub


Progress Event Example

This example updates a label on a form to show the progress of synchronization. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Dim WithEvents mySync As Outlook.SyncObject
Dim myForm As New Form1

Sub Initialize_handler()
    Set mySync = myOlApp.Session.SyncObjects.Item(1)
End Sub

Private Sub mySync_Progress(ByVal State As Outlook.OlSyncState, ByVal Description As String, ByVal Value As Long, ByVal Max As Long)
    If State = olSyncStarted then
        Cap = "Synchronization started: "
    Else
        Cap = "Synchronization stopped: "
    End If
    Cap = Cap & Str(State / Max * 100) & "% " & Description
    Form1.Label1.Caption = Cap
End Sub


 PropertyChange Event Example

PropertyChange Event Example

This example uses the PropertyChange event to disable the setting of a reminder on an item.

Sub Item_PropertyChange(ByVal myPropertyName)
    Select Case myPropertyName
        Case "ReminderSet"
            MsgBox "You may not set a reminder on this item!"
            Item.ReminderSet = False
        Case Else
    End Select
End Sub


Quit Event Example

This example displays a farewell message when Microsoft Outlook exits. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Outlook.

Dim WithEvents myOlApp As Outlook.Application

Sub Initialize_handler()
    Set myOlApp = CreateObject("Outlook.application")
End Sub

Private Sub myOlApp_Quit()
    MsgBox "Goodbye, " & Application.GetNamespace("MAPI").CurrentUser
End Sub


 Read Event Example

Read Event Example

This VBScript example uses the Read event to increment a counter that tracks how often an item is read.

Sub Item_Read()
    Set myProperty = Item.UserProperties("ReadCount")
    myProperty.Value = myProperty.Value + 1
    Item.Save
End Sub


Reminder Event Example

This Microsoft Visual Basic/Visual Basic for Applications example tests the item generating the reminder to determine if it is a mail item. If it is, the example uses the ReplyAll method to create and display a new mail item. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim WithEvents myolapp As Outlook.Application

Sub Initialize_handler()
    Set myolapp = CreateObject("Outlook.application")
End Sub

Private Sub myolapp_Reminder(ByVal Item As Object)
    Dim myReplyItem As Outlook.MailItem
    If TypeName(Item) = "MailItem" Then
        Set myReplyItem = Item.ReplyAll
        myReplyItem.Display
    End If
End Sub


 ReplyAll Event Example

ReplyAll Event Example

This VBScript example uses the ReplyAll event and reminds the user that proceeding will reply to all original recipients of an item and, depending on the user's response, either allows the action to continue or stops it.

Function Item_ReplyAll(ByVal myResponse)
    myMsg = "Do you really want to reply to all original recipients?"
myResult = MsgBox(myMsg, 289, "Flame Protector")
    If myResult = 1 Then
        Item_ReplyAll = True
    Else
        Item_ReplyAll = False
    End If
End Function


 Reply Event Example

Reply Event Example

This VBScript example uses the Reply event and sets the Sent Items folder for the reply item to the folder in which the original item resides.

Function Item_Reply(ByVal myResponse)
    Set myResponse.SaveSentMessageFolder = Item.Parent
End Function


SelectionChange Event Example

This example changes the caption of a form named Form1 to show the number of items selected in the topmost explorer window. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As Outlook.Application
Public WithEvents myOlExp As Outlook.Explorer

Public Sub Initialize_handler()
    Set myOlExp = myOlApp.ActiveExplorer
End Sub

Private Sub myOlExp_SelectionChange()
    Form1.Caption = myOlExp.Selection.Count & " items selected."
End Sub


 Send Event Example

Send Event Example

This VBScript example uses the Send event and sends an item with an automatic expiration date of one week.

Function Item_Send()
    Item.ExpiryTime = Date + 7
End Function


ShortcutAdd Event Example

This example changes the name of a Calendar shortcut when it is added to the first group in the Outlook Bar. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Dim WithEvents myOlSCuts As Outlook.OutlookBarShortcuts
Dim myOlBar As Outlook.OutlookBarPane

Sub Initialize_handler()
    Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
    Set myOlSCuts = myOlBar.Contents.Groups.Item(1).Shortcuts
End Sub

Private Sub myOlSCuts_ShortcutAdd(ByVal NewShortcut As Outlook.OutlookBarShortcut)
    Dim myNS As Outlook.NameSpace
    Set myNS = myOlApp.GetNamespace("MAPI")
    If NewShortcut.Target.Name = "Calendar" Then
        NewShortcut.Name = myNS.CurrentUser & "'s Schedule"
    End If
End Sub


Startup Event Example

This Microsoft Outlook Visual Basic for Applications example maximizes the Outlook explorer window when Outlook starts.

Private Sub Application_Startup()
    Application.ActiveExplorer.WindowState = olMaximized
End Sub


SyncEnd Event Example

This example updates a label on a form to indicate that synchronization has finished and changes the enabled state of buttons on the form. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Dim WithEvents mySync As Outlook.SyncObject
Dim myForm As New Form1

Sub Initialize_handler()
    Set mySync = myOlApp.Session.SyncObjects.Item(1)
End Sub

Private Sub mySync_SyncEnd()
    Form1.Label1.Caption = "Synchronization complete."
    Form1.Command1.Enabled = True
    Form1.Command2.Enabled = False
End Sub


SyncStart Event Example

This example updates a label on a form to show that synchronization has started. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myOlApp As New Outlook.Application
Dim WithEvents mySync As Outlook.SyncObject
Dim myForm As New Form1

Sub Initialize_handler()
    Set mySync = myOlApp.Session.SyncObjects.Item(1)
End Sub

Private Sub mySync_SyncStart()
    Form1.Label1.Caption = "Synchronization started"
End Sub


ViewSwitch Event Example

This example hides the preview pane if it is visible when the user switches to the Messages with AutoPreview view. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Microsoft Outlook.

Dim myolapp As New Outlook.Application
Dim WithEvents myOlExpl As Outlook.Explorer

Sub Initialize_handler()
    Set myOlExpl = myolapp.ActiveExplorer
End Sub

Private Sub myOlExpl_ViewSwitch()
    If myOlExpl.CurrentView = "Messages with AutoPreview" And myOlExpl.IsPaneVisible(olPreview) = True Then
        myOlExpl.ShowPane olPreview, False
    End If
End Sub


 Write Event Example

Write Event Example

This VBScript example uses the Write event and warns the user that the item is about to be saved and will overwrite any existing item and, depending on the user's response, either allows the operation to continue or stops it.

Function Item_Write()
    myMsg = "The item is about to be saved. Do you wish to overwrite the existing item?"
    myResult = MsgBox(myMsg, 289, "Save")
    If myResult = 1 Then
        Item_Write = True
    Else
        Item_Write = False
    End If
End Function


What was new for Microsoft Outlook 98 developers

The following tables identify the new methods, objects, and properties in the Microsoft Outlook 98 Object Library.

New Methods

Add (AddressEntries) | Details
ForwardAsVcal | ForwardAsVcard
GetFirst | GetFreeBusy
GetLast | GetNext
GetOccurrence | GetPrevious
PickFolder | ResetColumns
SetColumns | Update

New Objects

AddressEntries Collection | AddressEntry
AddressLists Collection | AddressList
DocumentItem | Exception
Exceptions Collection | MeetingItem (formerly MeetingRequestItem)
TaskRequestAcceptItem | TaskRequestDeclineItem
TaskRequestUpdateItem |

New Properties

AddressEntries | AddressEntry
AddressLists | AppointmentItem
Class | CompanyLastFirstNoSpace
CompanyLastFirstSpaceOnly | Deleted
DisplayType | EditorType
Exceptions | HTMLBody
HTMLEditor | ID
Index | InternetFreeBusyAddress
IsOnlineMeeting | IsReadOnly
Manager | Members
LastFirstAndSuffix | LastFirstNoSpace
LastFirstNoSpaceCompany | LastFirstSpaceOnly
LastFirstSpaceOnlyCompany | NetMeetingAlias
NetMeetingAutoStart | NetMeetingOrganizerAlias
NetMeetingServer | NetMeetingType
OriginalDate | RecurrenceState
ScriptText | Sent
Session | Submitted
WordEditor |


Help topic not available

Please click the Back button to go back to your original topic or click Help Topics to view the table of contents.


Help Topic Not Available

The Help topic cannot be displayed because Microsoft Office Visual Basic Help cannot be found, was not installed, or was removed.

To install Microsoft Office Visual Basic Help

  1. In Control Panel, double-click Add/Remove Programs.

  2. On the Install/Uninstall tab, click the edition of Microsoft Office 2000 that's installed, and then click Add/Remove.

  3. Click Add or Remove Features, and then expand Office Tools in the list of features.

  4. Click the icon next to Visual Basic Help to view the installation choices.

  5. Click Run from My Computer or Run from Network, and then click Update Now.


New Events (Alphabetical)

Events that have been added to existing objects in Microsoft Outlook 2000 are listed in the following table (sorted alphabetically).

Event | Objects
Activate | Explorer, Inspector
AttachmentAdd | All Outlook Items
AttachmentRead | All Outlook Items
BeforeAttachmentSave | All Outlook Items
BeforeCheckNames | All Outlook Items
BeforeFolderSwitch | Explorer
BeforeViewSwitch | Explorer
Deactivate | Explorer, Inspector
FolderAdd | Folders
FolderChange | Folders
FolderRemove | Folders
FolderSwitch | Explorer
ItemAdd | Items
ItemChange | Items
ItemRemove | Items
ItemSend | Application
NewMail | Application
OptionsPagesAdd | Application, NameSpace
Reminder | Application
SelectionChange | Explorer
ViewSwitch | Explorer


New Events (by Object)

Events that have been added to existing objects in Microsoft Outlook 2000 are listed in the following table (sorted by object name).

Object | Events
All Outlook Items | AttachmentAdd AttachmentRead BeforeAttachmentSave BeforeCheckNames
Application | ItemSend NewMail OptionsPagesAdd Reminder
Explorer | Activate BeforeFolderSwitch BeforeViewSwitch Deactivate FolderSwitch SelectionChange ViewSwitch
Folders | FolderAdd FolderChange FolderRemove
Inspector | Activate Deactivate
Items | ItemAdd ItemChange ItemRemove
NameSpace | OptionsPagesAdd


New Methods (Alphabetical)

Methods that have been added to existing objects in Microsoft Outlook 2000 are listed in the following table (sorted alphabetically).

Method | Objects
Activate | Explorer, Inspector
ActiveWindow | Application
IsPaneVisible | Explorer
ShowPane | Explorer


New Methods (by Object)

Methods that have been added to existing objects in Microsoft Outlook 2000 are listed in the following table (sorted by object name).

Object | Methods
Application | ActiveWindow
Explorer | Activate IsPaneVisible ShowPane
Inspector | Activate


 New Objects

New Objects

Objects that were added to the Microsoft Outlook 2000 object model are listed in the following table.

Object | Description
AnswerWizard | Represents the Answer Wizard.
COMAddIns Collection | Contains COMAddIn objects representing all COM add-ins loaded in Outlook.
DistListItem | Represents a distribution list in a contacts folder.
Explorers Collection | Contains Explorer objects representing all explorer windows.
Inspectors Collection | Contains Inspector objects representing all inspector windows.
LanguageSettings | Contains information about language settings used by Outlook.
Link | Represents an item that is linked to another Outlook item.
Links Collection | Contains Link objects representing all items linked to a particular item.
OutlookBarGroup | Represents a group of shortcuts on the Outlook Bar
OutlookBarGroups Collection | Contains OutlookBarGroup objects representing all shortcut groups on the Outlook Bar.
OutlookBarPane | Represents the Outlook Bar
OutlookBarShortcut | Represents a shortcut on the Outlook Bar
OutlookBarShortcuts Collection | Contains OutlookBarShortcut objects representing all the shortcuts in an Outlook Bar group
OutlookBarStorage | Represents the storage for objects in the Outlook Bar
Panes | Contains objects representing panes in an explorer
PropertyPage | Represents a custom page added to the Outlook Options dialog box or a folder Properties dialog box.
PropertyPages Collection | Contains PropertyPage objects representing all the custom pages added to a dialog box.
PropertyPageSite | Represents the container of a custom property page.
Selection Collection | Contains a set of Outlook items representing the items currently selected in an explorer.
SyncObject | Represents a synchronization profile for a user.
SyncObjects Collection | Contains SyncObject objects representing the synchronization profiles for a user.


New Properties (Alphabetical)

Properties that have been added to existing objects in Microsoft Outlook 2000 are listed in the following table (sorted alphabetically).

Property | Objects
AnswerWizard | Application
Caption | Explorer, Inspector
COMAddIns | Application
CurrentView | Explorer
Explorers | Application
Height , Width | Explorer, Inspector
Inspectors | Application
LanguageSettings | Application
Left , Top | Explorer, Inspector
Links | All Outlook Items
NetMeetingDocPathName | AppointmentItem
NetShowURL | AppointmentItem
Panes | Explorer
Selection | Explorer
SyncObjects | NameSpace
WebViewAllowNavigation | MAPIFolder
WebViewOn | MAPIFolder
WebViewURL | MAPIFolder
WindowState | Explorer, Inspector


New Properties (by Object)

Properties that have been added to existing objects in Microsoft Outlook 2000 are listed in the following table (sorted by object name).

Object | Properties
All Outlook Items | Links
Application | AnswerWizard COMAddIns Explorers Inspectors LanguageSettings
AppointmentItem | NetMeetingDocPathName NetShowURL
Explorer | Caption CurrentView Height, Width Left, Top Panes Selection WindowState
Inspector | Caption Height, Width Left, Top WindowState
MAPIFolder | WebViewAllowNavigation olproWebViewOn WebViewURL
NameSpace | SyncObjects


 Outlook Item Objects

Outlook Item Objects

Outlook items include

  • AppointmentItem

  • ContactItem

  • DistListItem

  • DocumentItem

  • JournalItem

  • MailItem

  • MeetingItem

  • NoteItem

  • PostItem

  • RemoteItem

  • ReportItem

  • TaskItem

  • TaskRequestAcceptItem

  • TaskRequestDeclineItem

  • TaskRequestItem

  • TaskRequestUpdateItem


Activate Method Example

This Microsoft Visual Basic/Visual Basic for Applications example responds to the NewMail event by activating the explorer window. The sample code must be placed in a class module, and the Initialize_handlers routine must be called before the event procedure can be called by Microsoft Outlook.

Public WithEvents myOlApp As Outlook.Application
Public WithEvents myOlExp As Outlook.Explorer

Public Sub Initialize_handlers()
    Set myOlApp = CreateObject("Outlook.Application")
    Set myOlExp = myOlApp.ActiveExplorer
End Sub

Private Sub myOlApp_NewMail()
    myOlExp.Activate
End Sub


ActiveExplorer Method Example

This Visual Basic for Applications example uses ActiveExplorer to demonstrate how to obtain an Explorer object for use, preferably getting the user's active explorer, but creating a new one for myFolder if there isn't already one on the desktop.

Set myOlApp = CreateObject("Outlook.Application")
Set myExplorer = myOlApp.ActiveExplorer
If TypeName(myExplorer) = "Nothing" Then
    Set myExplorer = myFolder.GetExplorer
End If


 ActiveInspector Method Example

ActiveInspector Method Example

This Visual Basic for Applications example uses the ActiveInspector method to demonstrate how to obtain the currently active Inspector object and display the name of the item that the inspector is displaying.

Set myOlApp = CreateObject("Outlook.Application")
Set myInspector = myOlApp.ActiveInspector
MsgBox "The active item is " & myInspector.CurrentItem.Subject

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myInspector = Application.ActiveInspector
MsgBox "The active item is " & myInspector.CurrentItem.Subject


ActiveWindow Method Example

This Microsoft Visual Basic/Visual Basic for Applications example minimizes the topmost Microsoft Outlook window if it is an inspector window.

Dim myOlApp As New Outlook.Application
If TypeName(myOlApp.ActiveWindow) = "Inspector" Then
    myOlApp.ActiveWindow.WindowState = olMinimized
End If

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

If TypeName(Application.ActiveWindow) = "Inspector" Then
    Application.ActiveWindow.WindowState = 1
End If


 Add Method (Actions Collection)

Add Method (Actions Collection)

Creates a new action in the Actions collection, and returns the new action as an Action object.

Syntax

objActions.Add

objActions Required. An expression that returns an Actions collection object.


Add Method (Actions Collection) Example

This Visual Basic for Applications example creates a new mail message and uses the Add method to add an Action to it.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myAction = myItem.Actions.Add

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(0)
Set myAction = myItem.Actions.Add


 Add Method (AddressEntries Collection)

Add Method (AddressEntries Collection)

Creates a new address entry in the AddressEntries collection, and returns the new address as an AddressEntry object.

Note New entries or changes to existing entries are not persisted in the collection until after calling the Update method.

Syntax

objAddressEntries.Add(Type, [Name], [Address])

objAddressEntries Required. An expression that returns an AddressEntries collection object.

Type Required. String. The type of the address entry.

Name Optional. String. Display name for the address entry.

Address Optional. String. The e-mail address of the address entry.


Add Method (AddressEntries Collection) Example

This VBScript example uses the Click event of a CommandButton. The name in the "To" field of the form is located in the Global Address List as well as the manager for that person. Both of these entries are added to the sender's Personal Address Book using the Add method.

Sub CommandButton1_Click()
    myName = Item.To
    Set myNameSpace = Application.GetNameSpace("MAPI")
    Set myGAddressList = myNameSpace.AddressLists("Global Address List")
    Set myGEntries = myGAddressList.AddressEntries
    Set myGEntry = myGEntries(myName)
    myManager = myGEntry.Manager
    Set myGEntry2 = myGEntries(myManager)
    Set myPAddressList = myNameSpace.AddressLists("Personal Address Book")
    Set myPEntries = myPAddressList.AddressEntries
    'Add a new AddressEntry object to the personal
    'address collection with the name, address, and
    'manager of the name in your To field.
    Set myPEntry = myPEntries.Add("Microsoft Mail Address", myName)
    myPEntry.Address = myGEntry.Address
    myPEntry.Manager = myGentry.Manager
    'Update to persist the collection.
    myPEntry.Update
    'Now add the manager's info. to
    'the Personal address collection.
    Set myPEntry2 = myPEntries.Add("Microsoft Mail Address", myManager)
    myPEntry2.Address = myGEntry2.Address
    myPEntry2.Manager = myGentry2.Manager
    myPEntry2.Update
End Sub


 Add Method (Attachments Collection)

Add Method (Attachments Collection)

Creates a new attachment in the Attachments collection, and returns the new attachment as an Attachment object.

Syntax

objAttachments.Add(Source, [Type], [Position], [DisplayName])

objAttachments Required. An expression that returns an Attachments collection object.

Source Required Variant. The file (represented by the full path and file name) or item that constitutes the attachment.

Type Optional Long. The type of attachment. Can be one of the following OlAttachmentType constants: olByReference(4), olByValue(1), or olEmbeddedItem(5).

Position Optional Long. The position of the attachment within the body text of the message.

DisplayName Optional String. The display name of the attachment. Ignored unless Type is set to olByValue.

Remarks

The following table describes the purpose of each OlAttachmentType constant value.

Constant | Use to
olByReference | Create a shortcut to an external file
olByValue | Embed attachment in the item
olEmbeddedItem | Create a shortcut to an Outlook item

When an Attachment is added to the Attachments collection of an item, the Type property of the Attachment will always return olOLE(6) until the item is saved.

To ensure consistent results, always save an item before adding or removing objects in the Attachments collection of the item.


Add Method (Attachments Collection) Example

This Visual Basic for Applications example uses CreateItem to create a new mail message, attaches a Microsoft Excel workbook as an attachment (not a link) using the Attachments property and gives the attachment a descriptive caption.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myAttachments = myItem.Attachments
myAttachments.Add "C:\My Documents\Q496.xls", _
    olByValue, 1, "4th Quarter 1996 Results Chart"

This Visual Basic for Applications example creates a new mail message and attaches a Microsoft Word document from a server using a link.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myAttachments = myItem.Attachments
Set myAttachment = myAttachments.Add _
"\\MYSVR1\Reports\Q496Report.doc", _
    olByReference

This Visual Basic for Applications example creates a new mail message and attaches the first contact in the default Contacts folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(olFolderContacts)
Set myFirstContact = myFolder.Items(1)
Set myItem = myOlApp.CreateItem(olMailItem)
Set myAttachments = myItem.Attachments
myAttachments.Add myFirstContact

This example shows how to perform the same action using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(10)
Set myFirstContact = myFolder.Items(1)
Set myItem = Application.CreateItem(0)
Set myAttachments = myItem.Attachments
myAttachments.Add myFirstContact


 Add Method (Explorers Collection)

Add Method (Explorers Collection)

Creates a new explorer window and returns the resulting Explorer object.

Syntax

object.Add(Folder[, DisplayMode])

object Required. An expression that returns an Explorers collection object.

Folder Required. The MAPIFolder object to display in the explorer window when it is created.

DisplayMode Optional Long. The display mode of the folder. Can be one of the following OlFolderDisplayMode constants: olFolderDisplayFolderOnly(1), olFolderDisplayNoNavigation(2) or olFolderDisplayNormal(0). The default value is olFolderDisplayNormal(0).

Remarks

The explorer window is initially hidden. You must call the Display of the Explorer object to make it visible.


Add Method (Explorers Collection) Example

The following Microsoft Visual Basic/Visual Basic for Applications example displays the Drafts folder in an explorer window without an Outlook Bar or Folder List.

Dim myOlApp As New Outlook.Application
Dim myExplorers As Outlook.Explorers
Dim myOlExpl As Outlook.Explorer
Dim myFolder As Outlook.MAPIFolder
Set myExplorers = myOlApp.Explorers
Set myFolder = myOlApp.GetNamespace("MAPI").GetDefaultFolder _
    (olFolderDrafts)
Set myOlExpl = myExplorers.Add _
    (myFolder, olFolderDisplayNoNavigation)
myOlExpl.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myExplorers = Application.Explorers
Set myFolder = Application.GetNamespace("MAPI").GetDefaultFolder(16)
Set myOlExpl = myExplorers.Add(myFolder, 2)
myOlExpl.Display


 Add Method (Folders Collection)

Add Method (Folders Collection)

Creates a new folder in the Folders collection, and returns the new folder as a MAPIFolder object.

Syntax

objFolders.Add(Name, [Type])

objFolders Required. An expression that returns a Folders object.

Name Required String. The display name for the new folder.

Type Optional Long. The Outlook folder type for the new folder. If the folder type is not specified, the new folder will default to the same type as the folder in which it is created. Can be one of the following OlDefaultFolders constants: olFolderCalendar(9), olFolderContacts(10), olFolderDrafts(16), olFolderInbox(6), olFolderJournal(11), olFolderNotes(12), or olFolderTasks(13). (The constants olFolderDeletedItems(3), olFolderOutbox(6), and olFolderSentMail(5) cannot be specified for this argument.)


Add Method (Folders Collection) Example

This Visual Basic for Applications example uses the Add method to add the new folder named "My Contacts" to the current (default) Contacts folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderContacts)
Set myNewFolder = myFolder.Folders.Add("My Contacts")

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(10)
Set myNewFolder = myFolder.Folders.Add("My Contacts")

This Visual Basic for Applications example uses the Add method to add two new folders in the Tasks folder. The first folder, "Notes Folder", will contain note items. The second folder, "Contacts Folder", will contain contact items. If the folders already exist, a message box will inform the user.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderTasks)
On Error GoTo ErrorHandler
Set myNotesFolder = myFolder.Folders.Add ("Notes Folder", olFolderNotes)
On Error GoTo ErrorHandler
Set myContactFolder = myFolder.Folders.Add ("Contacts Folder", olFolderContacts)
Exit Sub
ErrorHandler:
    MsgBox "This folder already exists!"


 Add Method (Inspectors Collection)

Add Method (Inspectors Collection)

Creates a new inspector window and returns the resulting Inspector object.

Syntax

object.Add(Item)

object Required. An expression that returns an Inspectors collection object.

Item Required item. The item to display in the inspector window when it is created.

Remarks

This method is essentially identical to the GetInspector property.


Add Method (Inspectors Collection) Example

This Microsoft Visual Basic/Visual Basic for Applications example prompts the user for a company name, uses the Restrict method to locate all contact items in the Contacts folder with that name, and displays each one.

Dim myOlApp As New Outlook.Application
Answer = InputBox("Enter the company name")
Set myFolder = myOlApp.GetNamespace("MAPI") _
    .GetDefaultFolder(olFolderContacts)
Set myItems = myFolder.Items.Restrict("[MessageClass] = 'IPM.Contact'")
Set myRestrictItems = myItems.Restrict("[CompanyName] = " & Answer)
For x = 1 To myRestrictItems.Count
    Set myInspector = myOlApp.Inspectors.Add(myRestrictItems.Item(x))
    myInspector.Display
Next x

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Answer = InputBox("Enter the company name")
Set myFolder = _
    Application.GetNamespace("MAPI").GetDefaultFolder(10)
Set myItems = myFolder.Items.Restrict("[MessageClass] = 'IPM.Contact'")
Set myRestrictItems = myItems.Restrict("[CompanyName] = " & Answer)
For x = 1 To myRestrictItems.Count
    Set myInspector = Application.Inspectors.Add(myRestrictItems.Item(x))
    myInspector.Display
Next


 Add Method (Items Collection)

Add Method (Items Collection)

Creates a new Outlook item in the Items collection for the folder, and returns the new item. If not specified, the Type of the item defaults to the type of the folder, or to MailItem if the parent folder is not typed.

Syntax

objItems.Add([Type])

objItems Required. An expression that returns an Items collection object.

Type Optional. Variant. The Outlook item type for the new item. Can be one of the following OlItemType constants: olAppointmentItem(1), olContactItem(2), olJournalItem(4), olMailItem(0), olNoteItem(5), olPostItem(6), or olTaskItem(3) or any valid message class. Specify the MessageClass to create custom forms.


Add Method (Items Collection) Example

This Visual Basic for Applications example gets the current Contacts folder and adds a new ContactItem object to it.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
    myNamespace.GetDefaultFolder(olFolderContacts)
Set myItem = myFolder.Items.Add

This Visual Basic for Applications example adds a custom form to the default Tasks folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
    myNamespace.GetDefaultFolder(olFolderTasks)
Set myItems = myFolder.Items
Set myItem = myItems.Add("IPM.Task.myTask")


 Add Method (Links Collection)

Add Method (Links Collection)

Links an item to another item by adding a Link object to the Links collection associated with the item.

Syntax

object.Add(Item)

object Required. An expression that returns a Links collection object.

Item Required. The item to be linked to the item associated with the Links collection. For Microsoft Outlook 2000, this must be a ContactItem object.


 Add Method (Links Collection) Example

Add Method (Links Collection) Example

This Microsoft Visual Basic/Visual Basic for Applications example creates a new task item, then prompts the user for the name of a contact to link to the item. If the contact is found, it is added to the item’s Links collection.

Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myTask As Outlook.TaskItem
Dim myContact As Outlook.ContactItem
Set myTask = myOlApp.CreateItem(olTaskItem)
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
tempstr = InputBox("Enter the name of the contact to link to this task")
If tempstr <> "" Then
    tempstr = "[Full Name] = """ & tempstr & """"
    Set myItems = myFolder.Items.Restrict("[MessageClass] = 'IPM.Contact'")
    Set myContact = myItems.Find(tempstr)
    myTask.Links.Add myContact
myTask.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myTask = Application.CreateItem(3)
Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(10)
tempstr = InputBox("Enter the name of the contact to link to this task")
If tempstr <> "" Then
    tempstr = "[Full Name] = """ & tempstr & """"
    Set myItems = myFolder.Items.Restrict("[MessageClass] = 'IPM.Contact'")
    Set myContact = myItems.Find(tempstr)
    myTask.Links.Add myContact
myTask.Display


AddMembers Method Example

This Microsoft Visual Basic/Visual Basic for Applications example creates a new distribution list and adds the current user to the list.

Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myDistList As Outlook.DistListItem
Dim myTempItem As Outlook.MailItem
Dim myRecipients As Outlook.Recipients
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myDistList = myOlApp.CreateItem(olDistributionListItem)
Set myTempItem = myOlApp.CreateItem(olMailItem)
Set myRecipients = myTempItem.Recipients
myDistList.DLName = _
    InputBox("Enter the name of the new distribution list")
myRecipients.Add myNameSpace.CurrentUser.Name
myDistList.AddMembers myRecipients
myDistList.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNamespace("MAPI")
Set myDistList = Application.CreateItem(7)
Set myTempItem = Application.CreateItem(0)
Set myRecipients = myTempItem.Recipients
myDistList.DLName = _
    InputBox("Enter the name of the new distribution list")
myRecipients.Add myNameSpace.CurrentUser.Name
myDistList.AddMembers myRecipients
myDistList.Display


 Add Method (OutlookBarGroups Collection)

Add Method (OutlookBarGroups Collection)

Adds a new, empty group in the Outlook Bar and returns the new group as an OutlookBarGroup object.

Syntax

object.Add(Name[, Index])

object Required. An expression that returns an OutlookBarGroups collection object.

Name Required String. The name of the group being created.

Index Optional Long. The position at which the new group will be inserted in the Outlook Bar. Position 1 is at the top of the bar.


Add Method (OutlookBarGroups Collection) Example

This Microsoft Visual Basic/Visual Basic for Applications example adds a group named Marketing as the second group in the Outlook Bar.

Dim myOlApp As New Outlook.Application
Dim myolBar As Outlook.OutlookBarPane
Set myolBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
myolBar.Contents.Groups.Add "Marketing", 2

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myolBar = Application.ActiveExplorer.Panes.Item("OutlookBar")
myolBar.Contents.Groups.Add "Marketing", 2


 Add Method (OutlookBarShortcuts Collection)

Add Method (OutlookBarShortcuts Collection)

Adds a new shortcut to a group in the Outlook Bar and returns the new shortcut as an OutlookBarShortcut object.

Syntax

object.Add(Target, Name[, Index])

object Required. An expression that returns an OutlookBarShortcuts collection object.

Target Required Variant. The target of the shortcut being created.

Name Required String. The name of the shortcut being created.

Index Optional Long. The position at which the new shortcut will be inserted in the Outlook Bar group. Position 0 is at the top of the group.

Remarks

The Target type depends on the shortcut type. If the type is MAPIFolder, the shortcut represents a Microsoft Outlook folder. If the type is a String, the shortcut represents a file-system path or a URL.


Add Method (OutlookBarShortcuts Collection) Example

The following Microsoft Visual Basic/Visual Basic for Applications example adds a shortcut to the Microsoft home page on the Web.

Dim myOlApp As New Outlook.Application
Dim myOlBar As Outlook.OutlookBarPane
Dim myolGroup As Outlook.OutlookBarGroup
Dim myOlShortcuts As Outlook.OutlookBarShortcuts
Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
Set myolGroup = myOlBar.Contents.Groups.Item(1)
Set myOlShortcuts = myolGroup.Shortcuts
myOlShortcuts.Add "http://www.microsoft.com", _
    "Microsoft Home Page", 3

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myOlBar = _
    Application.ActiveExplorer.Panes.Item("OutlookBar")
Set myolGroup = myOlBar.Contents.Groups.Item(1)
Set myOlShortcuts = myolGroup.Shortcuts
myOlShortcuts.Add "http://www.microsoft.com", _
    "Microsoft Home Page", 3


 Add Method (Pages Collection)

Add Method (Pages Collection)

Creates a new page in the Pages collection, and returns the new page. The Pages collection is initially empty and there is a limit of 5 customizable pages per collection.

Syntax

objPages.Add(Name)

objPages Required. An expression that returns a Pages collection object.

Name Required. String. The name of the page.


Add Method (Pages Collection) Example

This Visual Basic for Applications example returns a new custom page named "My Page" (the same call without a name will return the next available page for customization — for example, "Custom1").

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)
Set myPages = myItem.GetInspector.ModifiedFormPages
Set myPage = myPages.Add("My Page")


 Add Method (PropertyPages Collection)

Add Method (PropertyPages Collection)

Adds a new custom property page to the Microsoft Outlook Options dialog box or to the folder Properties dialog box.

Syntax

object.Add(Page[, Caption])

object Required. An expression that returns a PropertyPages collection object.

Page Required Variant. The property page being added to the dialog box.

Caption Optional. String. The caption to be displayed on the property-page tab.

Remarks

Page can be a PropertyPage object or a String containing the OLE programmatic identifier of the ActiveX control that implements the custom property page. If Page is a PropertyPage object, the property page must be implemented in an in-process DLL. If it is a programmatic identifier, then the property page can also be implemented in a stand-alone executable file or Microsoft Visual Basic for Applications program.


Add Method (PropertyPages Collection) Example

This Microsoft Visual Basic/Visual Basic for Applications example adds a new property page named Project Settings to the Microsoft Outlook Options dialog box. The sample code must be placed in a class module, and the Initialize_handler routine must be called before the event procedure can be called by Outlook.

Dim WithEvents myOlApp As Outlook.Application
Dim myPropertyPage As Outlook.PropertyPage

Sub Initialize_handler()
    Set myOlApp = CreateObject("Outlook.application")
End Sub

Private Sub myOlApp_OptionsPagesAdd(ByVal Pages As Outlook.PropertyPages)
    Set myPropertyPage = ProjPage
    Pages.Add  "myPropertyPage.Page1", "Project Settings"
End Sub


 Add Method (Recipients Collection)

Add Method (Recipients Collection)

Creates a new recipient in the Recipients collection, and returns the new recipient as a Recipient object.

Syntax

objRecipients.Add(Name)

objRecipients Required. An expression that returns a Recipients collection object.

Name Required String. The display name of the recipient.


Add Method (Recipients Collection) Example

This Visual Basic for Applications example creates a new mail message, uses the Add method to add "Allison Klein" as a To recipient, and displays the message.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myRecipient = myItem.Recipients.Add("Allison Klein")
myItem.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(0)
Set myRecipient = myItem.Recipients.Add("Allison Klein")
myItem.Display


AddStore Method Example

This Microsoft Visual Basic/Visual Basic for Applications example adds a new personal folder (.pst) file to the user’s profile.

Dim myOlApp As New Outlook.Application
Dim myNS As Outlook.NameSpace
Set myNS = myOlApp.GetNamespace("MAPI")
myNS.AddStore "c:\my documents\" & myNS.CurrentUser & ".pst"

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myNS = Application.GetNamespace("MAPI")
myNS.AddStore "c:\my documents\" & myNS.CurrentUser & ".pst"


 Add Method (UserProperties Collection)

Add Method (UserProperties Collection)

Creates a new user property in the UserProperties collection, and returns the new property as a UserProperty object.

Syntax

objUserProperties.Add(Name, Type, [AddToFolderFields], [DisplayFormat])

objUserProperties Required. An expression that returns a UserProperties collection object.

Name Required String. The name of the property.

Type Required Long. The type of the property. Can be one of the following OlUserPropertyType constants: olCombination(19), olCurrency(14), olDateTime(5), olDuration(7), olFormula(18), olKeywords(11), olNumber(3), olPercent(12), olText(1), or olYesNo(6).

AddToFolderFields Optional Boolean. True if the property will be added to the folder fields, False if not. The default value is True.

DisplayFormat Optional Long. The index of the format of the specified OlUserPropertyType constant. For more information, see the "Remarks" section.

Remarks

To look up the index of a format to specify for the DisplayFormat argument, follow these steps.

  1. Open a new item in design mode.

  2. Click an empty page. If the Field Chooser is not displayed, click the Field Chooser button on the toolbar.

  3. In the Field Chooser, click the New button.

  4. In the New Field dialog box, select the appropriate field type in the Type box, and then find the format you want in the Format box. The index of the format corresponds to its position in this list. The first user property has an index of 1.


Add Method (UserProperties Collection) Example

This Visual Basic for Applications example creates a new ContactItem object and adds "LastDateSpokenWith" as a user property.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)
Set myUserProperty = myItem.UserProperties _
    .Add("LastDateSpokenWith", olDateTime)

This Visual Basic for Applications example creates a new ContactItem object and adds "Notes" as a user property. The Value is set by accessing the index of the new property.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)
Set myUserProperty = myItem.UserProperties _
    .Add("Notes", olText)
myItem.UserProperties(1).Value = "Neighbor"


Apply Method Example

This Microsoft Visual Basic/Visual Basic for Applications example sets two global variables to reflect the values in controls on a form and then sets a global variable representing the Dirty property to False.

Private Sub PropertyPage_Apply()
    globWorkGroup = Form1.Text1.Text
    globUserType = Form1.Combo1.Text
    globDirty = False
End Sub


Assign Method Example

This Visual Basic for Applications example uses CreateItem to create a simple task and delegate it as a task request to another user.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olTaskItem)
myItem.Assign
Set myDelegate = myItem.Recipients.Add("April LaMonte")
myItem.Subject = "Prepare Agenda For Meeting"
myItem.DueDate = #9/20/97#
myItem.Send

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(3)
myItem.Assign
Set myDelegate = myItem.Recipients.Add("April LaMonte")
myItem.Subject = "Prepare Agenda For Meeting"
myItem.DueDate = #9/20/97#
myItem.Send


Close Method Example

This Visual Basic for Applications example uses CreateItem to open a mail message, adds a recipient to it to introduce a change, then uses the Close method to close the item and prompt the user to save changes.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.Recipients.Add "David Goodhand"
myItem.Close olPromptForSave

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(0)
myItem.Recipients.Add "David Goodhand"
myItem.Close 2


CopyTo Method Example

This Visual Basic for Applications example uses the CopyTo method to copy the current folder (in this case, the default Contacts folder) to the default Inbox folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myInboxFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myCurrentFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
Set myNewFolder = myCurrentFolder.CopyTo(myInboxFolder)

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myInboxFolder = myNameSpace.GetDefaultFolder(6)
Set myCurrentFolder = myNameSpace.GetDefaultFolder(10)
Set myNewFolder = myCurrentFolder.CopyTo(myInboxFolder)


Copy Method Example

This Visual Basic for Applications example creates a mail message, sets the Subject to "Speeches", uses the Copy method to copy it, then moves the copy into a newly-created mail folder named "Saved Mail" within the Tasks folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
Set myNewFolder = myFolder.Folders.Add("Saved Mail", olFolderDrafts)
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.Subject = "Speeches"
Set myCopiedItem = myItem.Copy
myCopiedItem.Move myNewFolder

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNamespace = Application.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(6)
Set myNewFolder = myFolder.Folders.Add("Saved Mail", 16)
Set myItem = Application.CreateItem(0)
myItem.Subject = "Speeches"
Set myCopiedItem = myItem.Copy
myCopiedItem.Move myNewFolder


CreateItemFromTemplate Method Example

This Visual Basic for Applications example uses CreateItemFromTemplate to create a new item from an Outlook template and then displays it.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItemFromTemplate _
    ("C:\Program Files\Microsoft Office\Templates\Outlook\While You Were Out.oft")
myItem.Display

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItemFromTemplate _
    ("C:\Program Files\Microsoft Office\Templates\Outlook\While You Were Out.oft")
myItem.Display


 CreateItem Method Example

CreateItem Method Example

This Visual Basic for Applications example uses the CreateItem method to create a new contact in the default Contacts folder and then displays the new item.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
Set myItem = myOlApp.CreateItem(olContactItem)
myItem.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(10)
Set myItem = Application.CreateItem(2)
myItem.Display


 CreateObject Method Example

CreateObject Method Example

This VBScript example utilizes the Open event of the item to access Microsoft Internet Explorer and display the Microsoft Web page.

Sub Item_Open()
   Set Web = CreateObject("InternetExplorer.Application")
   Web.Visible = TRUE
   Web.Navigate "www.microsoft.com"
End Sub

This VBScript example utilizes the Click event of a CommandButton on the item to access Microsoft Word and open a document on the root directory named "Resume.doc".

Sub CommandButton1_Click()
    Set Word = CreateObject("Word.Application")
    Word.Visible = TRUE
    Word.Documents.Open("C:\Resume.doc")
End Sub


CreateRecipient Method Example

This Visual Basic for Applications example uses the CreateRecipient method to obtain the default Calendar folder for the user Eric Lang.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myRecipient = myNameSpace.CreateRecipient("Eric Lang")
Set hisCalendar = myNameSpace.GetSharedDefaultFolder _
    (myRecipient, olFolderCalendar)

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myRecipient = myNameSpace.CreateRecipient("Eric Lang")
Set hisCalendar = myNameSpace.GetSharedDefaultFolder _
    (myRecipient, 9)


Delete Method Example

This Visual Basic for Applications example uses the GetFirst method to locate the first folder in the Tasks folder and then uses the Delete method to delete the folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderTasks)
Set myOldFolder = myFolder.Folders.GetFirst
myOldFolder.Delete

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(13)
Set myOldFolder = myFolder.Folders.GetFirst
myOldFolder.Delete


Details Method Example

This Visual Basic for Applications example uses the Add method to add a new AddressEntry to the Personal Address Book. The Name, "John Q. Public" is necessary to avoid errors.

If this entry already exists, the code skips to DialogBox:. The Details method displays a dialog box that shows the information for this entry.

Set myOlApp = CreateObject("Outlook.Application")
    Set myNamespace = myOlApp.GetNamespace("MAPI")
    Set myAddrList = myNamespace.AddressLists("Personal Address Book")
    Set myAddrEntries = myAddrList.AddressEntries
    Set myEntry = myAddrEntries.Add("Microsoft Mail Address")
    myEntry.Name = "John Q. Public"
    On Error GoTo DialogBox
    myEntry.Address = "someone@microsoft.com"
    myEntry.Update
DialogBox:
    myEntry.Details


 Display Method Example

Display Method Example

This Visual Basic for Applications example uses the Display method to display the default Inbox folder. This example will not return an error, even if there are no items in the Inbox, because you are not asking for the display of a specific item.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
myFolder.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(6)
myFolder.Display

This Visual Basic for Applications example displays the first item in the Inbox folder. This example will return an error if the Inbox is empty, because you are attempting to display a specific item. If there are no items in the folder, a message box will be displayed to inform the user.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
On Error GoTo ErrorHandler
myFolder.Items(1).Display
Exit Sub
ErrorHandler:
    MsgBox "There are no items to display! "


Execute Method Example

This Visual Basic for Applications example uses the Execute method to look through all the actions for the given mail message, and executes the action called "Reply to All."

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
On Error GoTo ErrorHandler
Set myItem = myOlApp.ActiveInspector.CurrentItem
For Each a In myItem.Actions
    If a.Name = "Reply to All" Then
        Set myItem2 = a.Execute
        Exit For
    End If
Next a
Exit Sub
ErrorHandler:
    MsgBox "There is no current item!"


FindNext Method Example

This Visual Basic for Applications example uses the GetDefaultFolder method to return the MAPIFolder object that represents the default Calendar folder for the current user. It then uses the Find and FindNext methods to locate all the appointments that occur today and display them in a series of message boxes.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
tdystart = Format(Date, "Short Date") & " 12:00 AM"
tdyend = Format(Date, "Short Date") & " 11:59 PM"
Set myAppointments = myNameSpace.GetDefaultFolder _
    (olFolderCalendar).Items
Set currentAppointment = myAppointments.Find("[Start] >= """ & _
    tdystart & """ and [Start] <= """ & tdyend & """")
While TypeName(currentAppointment) <> "Nothing"
    MsgBox currentAppointment.Subject
    Set currentAppointment = myAppointments.FindNext
Wend


Find Method Example

This Visual Basic for Applications example opens the default Calendar folder and uses the Find method to find the first appointment whose subject is "Golf w/ Jerry Wheeler."

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myCalendar = myNameSpace.GetDefaultFolder (olFolderCalendar)
Set myItem = myCalendar.Items.Find("[Subject] = _
    ""Golf w/ Jerry Wheeler""")

This Visual Basic for Applications example opens the default Contacts folder and finds the first contact filed as "Jones" whose first name is "Brent."

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myContacts = myNameSpace.GetDefaultFolder (olFolderContacts)
Set myItem = myContacts.Items.Find("[FileAs] = _
    ""Jones"" and [FirstName] = ""Brent""")

This Visual Basic for Applications example utilizes UserProperties and finds a custom property named "LastDateContacted" for the contact.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myContacts = myNameSpace.GetDefaultFolder (olFolderContacts)
Set myContact = myContacts.Items.Find("[FileAs] = _
    ""Jones"" and [FirstName] = ""Brent""")
Set myProperty = _
    myContact.UserProperties.Find("LastDateContacted")
MsgBox "Last Date Contacted: " & myProperty.Value


 Forward Method Example

Forward Method Example

This Visual Basic for Applications example uses the GetDefaultFolder method to return the MAPIFolder object that represents the default Inbox folder for the current user. It then uses the Forward method to retrieve the first message in the default Inbox folder and forward it to Laura Jennings. The Add method is used to add Laura Jennings to the Recipients collection and the Send method sends the item to all recipients. It is assumed that the name will resolve unambiguously in the Address Book.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myForward = myFolder.Items(1).Forward
myForward.Recipients.Add "Laura Jennings"
myForward.Send

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(6)
Set myForward = myFolder.Items(1).Forward
myForward.Recipients.Add "Laura Jennings"
myForward.Send


GetAssociatedAppointment Method Example

This Visual Basic for Applications example finds a MeetingItem in the default Inbox folder and adds the associated appointment to the Calendar folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(olFolderInbox)
Set myMtgReq = myFolder.Items.Find _
    ("[MessageClass] = 'IPM.Schedule.Meeting.Request'")
If TypeName(myMtgReq) <> "Nothing" Then
   Set myAppt = myMtgReq.GetAssociatedAppointment(True)
End If

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(6)
Set myMtgReq = myFolder.Items.Find _
    ("[MessageClass] = 'IPM.Schedule.Meeting.Request'")
If TypeName(myMtgReq) <> "Nothing" Then
   Set myAppt = myMtgReq.GetAssociatedAppointment(True)
End If

This example accepts a meeting request, sending the response without displaying the inspector.

Set myNewMeeting = myMtgReq.GetAssociatedAppointment(True)
myNewMeeting.Respond olResponseAccepted, True


GetAssociatedTask Method Example

This example accepts a TaskRequestItem, sending the response without displaying the inspector.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myTasks = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myTaskReqItem = myTasks.Items.Find _
    ("[Subject] = ""Meeting w/ Jerry Wheeler""")
'The task is displayed.
myTaskReqItem.Display
Set myNewTaskItem = myTaskReqItem.GetAssociatedTask(True)
myNewTaskItem.Respond olTaskAccept, True, True

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myTasks = myNameSpace.GetDefaultFolder(6)
Set myTaskReqItem = myTasks.Items.Find _
    ("[Subject] = ""Meeting w/ Jerry Wheeler""")
'The task is displayed.
myTaskReqItem.Display
Set myNewTaskItem = myTaskReqItem.GetAssociatedTask(True)
myNewTaskItem.Respond 2, True, True


GetDefaultFolder Method Example

This Visual Basic for Applications example uses the GetDefaultFolder method to obtain the default Calendar folder for the current user.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myCalendar = myNameSpace.GetDefaultFolder(olFolderCalendar)

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myCalendar = myNameSpace.GetDefaultFolder(9)

This Visual Basic for Applications example returns the first folder in the Tasks Folders collection.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myTasks = myNameSpace.GetDefaultFolder(olFolderTasks)
Set myFolder = myTasks.Folders(1)


GetExplorer Method Example

This Visual Basic for Applications example uses the GetExplorer method to return a new, inactive Explorer for myFolder, and then displays it in the default mode of olFolderDisplayNormal.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myExplorer = myFolder.GetExplorer
myExplorer.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(6)
Set myExplorer = myFolder.GetExplorer
myExplorer.Display


 GetFolderFromID Method Example

GetFolderFromID Method Example

This Visual Basic for Applications example obtains the EntryID and StoreID for a subfolder within the Tasks Folders collection and then calls the GetFolderFromID method using these values to obtain the same subfolder. The folder is then displayed.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderTasks)
Set myOwnFolder = myFolder.Folders(1)
myEntryID = myOwnFolder.EntryID
myStoreID = myOwnFolder.StoreID
Set myNewFolder = myNameSpace.GetFolderFromID(myEntryID, myStoreID)
myNewFolder.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(13)
Set myOwnFolder = myFolder.Folders(1)
myEntryID = myOwnFolder.EntryID
myStoreID = myOwnFolder.StoreID
Set myNewFolder = myNameSpace.GetFolderFromID(myEntryID, myStoreID)
myNewFolder.Display


GetMember Method Example

This Microsoft Visual Basic/Visual Basic for Applications example locates every distribution list in the default Contacts folder and determines whether the list contains the current user.

Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myDistList As Outlook.DistListItem
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
For x = 1 To myFolder.Items.Count
    If TypeName(myFolder.Items.Item(x)) = "DistListItem" Then
        Set myDistList = myFolder.Items.Item(x)
        For y = 1 To myDistList.MemberCount
            If myDistList.GetMember(y).Name = myNameSpace.CurrentUser.Name Then
                MsgBox "Your are a member of " & myDistList.DLName
            End If
        Next y
    End If
Next x

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(10)
For x = 1 To myFolder.Items.Count
    If TypeName(myFolder.Items.Item(x)) = "DistListItem" Then
        Set myDistList = myFolder.Items.Item(x)
        For y = 1 To myDistList.MemberCount
            If myDistList.GetMember(y).Name = myNameSpace.CurrentUser.Name Then
                MsgBox "Your are a member of " & myDistList.DLName
            End If
        Next
    End If
Next


GetNameSpace Method Example

This Visual Basic for Applications example uses GetNameSpace to obtain the MAPI NameSpace object.

Set myOlApp = CreateObject ("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")


 GetOccurrence Method Example

GetOccurrence Method Example

This Visual Basic for Applications example uses CreateItem to create an AppointmentItem object. The RecurrencePattern is obtained for this item using the GetRecurrencePattern method. By setting the RecurrencePattern properties, RecurrenceType, PatternStartDate, and PatternEndDate, the appointments are now a recurring series that occur on a daily basis for the period of one year.

An Exception object is created when one instance of this recurring appointment is obtained using the GetOccurrence method and properties for this instance are altered. This exception to the series of appointments is obtained using the GetRecurrencePattern method to access the Exceptions collection associated with this series. Message boxes display the original Subject and OriginalDate for this exception to the series of appointments and the current date, time, and subject for this exception.

For a description of changes required for this example to work in VBScript, see the Note at the end of the example.

Public Sub cmdExample()
    Set myOlApp = New Outlook.Application
    Set myApptItem = myOlApp.CreateItem(olAppointmentItem)
    myApptItem.Start = #2/2/98 3:00:00 PM#
    myApptItem.End = #2/2/98 4:00:00 PM#
    myApptItem.Subject = "Meet with Boss"

    'Get the recurrence pattern for this appointment
    'and set it so that this is a daily appointment
    'that begins on 2/2/98 and ends on 2/2/99
     'and save it.
    Set myRecurrPatt = myApptItem.GetRecurrencePattern
    myRecurrPatt.RecurrenceType = olRecursDaily
    myRecurrPatt.PatternStartDate = #2/2/98#
    myRecurrPatt.PatternEndDate = #2/2/99#
    myApptItem.Save

    'Access the items in the Calendar folder to locate
    'the master AppointmentItem for the new series.
    Set myNamespace = myOlApp.GetNamespace("MAPI")
    Set myFolder = myNamespace.GetDefaultFolder(olFolderCalendar)
    Set myItems = myFolder.Items
    Set myApptItem = myItems("Meet with Boss")

    'Get the recurrence pattern for this appointment
    'and obtain the occurrence for 3/12/98.
    myDate = #3/12/98 3:00:00 PM#
    Set myRecurrPatt = myApptItem.GetRecurrencePattern
    Set myOddApptItem = myRecurrPatt.GetOccurrence(myDate)

    'Save the existing subject. Change the subject and
    'starting time for this particular appointment
    'and save it.
    saveSubject = myOddApptItem.Subject
    myOddApptItem.Subject = "Meet NEW Boss"
    newDate = #3/12/98 3:30:00 PM#
    myOddApptItem.Start = newDate
    myOddApptItem.Save

    'Get the recurrence pattern for the master
    'AppointmentItem. Access the collection of
    'exceptions to the regular appointments.
    Set myRecurrPatt = myApptItem.GetRecurrencePattern
    Set myException = myRecurrPatt.Exceptions.Item(1)

    'Display the original date, time, and subject
    'for this exception.
    MsgBox myException.OriginalDate & ": " & saveSubject

    'Display the current date, time, and subject
    'for this exception.
    MsgBox myException.AppointmentItem.Start & ": " &
myException.AppointmentItem.Subject
End Sub

Note For this example to work properly in VBScript, there are only a few simple changes that need to be made in the code.

You don't have to retrieve the application as an object and you must use the values of the constants, so:

Set myOlApp = New Outlook.Application
    Set myApptItem = myOlApp.CreateItem(olAppointmentItem)

becomes:

Set myApptItem = Application.CreateItem(1)

and

myRecurrPatt.RecurrenceType = olRecursDaily

becomes:

myRecurrPatt.RecurrenceType = 0

and

Set myFolder = myNamespace.GetDefaultFolder(olFolderCalendar)

becomes:

Set myFolder = myNamespace.GetDefaultFolder(9)


GetPageInfo Method Example

This Microsoft Visual Basic/Visual Basic for Applications example returns the name of the Help file and the context ID of the topic to be displayed.

Private Sub PropertyPage_GetPageInfo(HelpFile As String, HelpContext As Long)
    HelpFile = "ProjPage.chm"
    HelpContext = IDH_PageInfo
End Sub


GetRecurrencePattern Method Example

This Visual Basic for Applications example uses GetRecurrencePattern to obtain the RecurrencePattern for an appointment.

Set myOlApp = CreateObject("Outlook.Application")
Set myAppt = myOlApp.CreateItem(olAppointmentItem)
Set myPattern = myAppt.GetRecurrencePattern

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myAppt = Application.CreateItem(1)
Set myPattern = myAppt.GetRecurrencePattern


GetSharedDefaultFolder Method Example

This Visual Basic for Applications example uses the GetSharedDefaultFolder method to resolve the Recipient object representing Kim Buhler, and then returns her shared default Calendar folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myRecipient = myNameSpace.CreateRecipient("Kim Buhler")
myRecipient.Resolve
If myRecipient.Resolved Then
    Set KimCalendarFolder = _
        myNameSpace.GetSharedDefaultFolder _
        (myRecipient, olFolderCalendar)
End If

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myRecipient = myNameSpace.CreateRecipient("Kim Buhler")
myRecipient.Resolve
If myRecipient.Resolved Then
    Set KimCalendarFolder = _
        myNameSpace.GetSharedDefaultFolder _
        (myRecipient, 9)
End If


HideFormPage Method Example

This Visual Basic for Applications example uses HideFormPage to hide the "General" page of a newly-created ContactItem and then displays the item.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)
Set myPages = myItem.GetInspector.ModifiedFormPages
Set myPage = myPages.Add("General")
Set myInspector = myOlApp.ActiveInspector
myInspector.HideFormPage("General")
myItem.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(2)
Set myPages = myItem.GetInspector.ModifiedFormPages
Set myPage = myPages.Add("General")
Set myInspector = Application.ActiveInspector
myInspector.HideFormPage("General")
myItem.Display


IsPaneVisible Method Example

This Microsoft Visual Basic/Visual Basic for Applications sample uses the IsPaneVisible method to determine whether the Outlook Bar is visible and uses the ShowPane method to display it if it is not visible.

Dim myOlApp As New Outlook.Application
Set myOlExp = myOlApp.ActiveExplorer
If myOlExp.IsPaneVisible(olOutlookBar) = False Then
    myolexp.ShowPane olOutlookBar,True
End If

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myOlExp = Application.ActiveExplorer
If myOlExp.IsPaneVisible(1) = False Then
    myOlExp.ShowPane 1,True
End If


Item Method Example

This Visual Basic for Applications example returns the second MailItem object in the default Inbox folder. It assumes that at least two MailItem objects already exist.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(olFolderInbox)
Set mySecondItem = myFolder.Items.Item(2)

This Visual Basic for Applications example returns the "Forward" action from the Actions collection.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector.CurrentItem
Set myAction = myItem.Actions.Item("Forward")

This example returns a MAPIFolder object from a Folders collection.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolders = myNameSpace.Folders
Set myFolder = myFolders.Item("Public Folder")

This Visual Basic for Applications example also returns a MAPIFolder object from a Folders collection.

Set myOlApp = CreateObject("Outlook.Application")
Set myFolders = _
    myOlApp.ActiveExplorer.CurrentFolder.Folders
Set myFolder = myFolders.Item("Project X")

This Visual Basic for Applications example creates a contact, returns its empty Pages collection, adds three custom pages and then returns the first custom page from the collection.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)
Set myPages = myItem.GetInspector.ModifiedFormPages
myPages.Add "One"
myPages.Add "Two"
myPages.Add "Three"
Set myPage = myPages.Item("One")

This Visual Basic for Applications example creates a mail message, adds four Recipient objects, then returns the third recipient from the newly-created Recipients collection and sets it as a BCC recipient.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myRecipients = myItem.Recipients
myRecipients.Add("Rich Andrews")
myRecipients.Add("Robin Hjellin")
myRecipients.Add("Meng Phua")
myRecipients.Add("Kim Yoshida")
myRecipients.Item(3) = olBCC

This Visual Basic for Applications example returns the "Total Cost" user property from the "My Order Form" UserProperties collection.

Set myOlApp = CreateObject("Outlook.Application")
Set myItems = myOlApp.ActiveExplorer.CurrentItem.Items
Set myItem = myItems.Add("My Order Form")
Set myProperties = myItem.UserProperties
Set myProperty = myProperties.Item("Total Cost")


 Logon Method Example

Logon Method Example

This Visual Basic for Applications example uses the Logon method to log on to a new session, displaying the dialog box to verify the profile name and password.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
myNameSpace.Logon "myProfile", "myPassword", True, True


MoveTo Method Example

This Visual Basic for Applications example adds a new folder to the default Contacts folder, and then uses the MoveTo method to move it to the default Inbox folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
Set myNewFolder = myFolder.Folders.Add("My Contacts")
myNewFolder.MoveTo myNameSpace.GetDefaultFolder(olFolderInbox)

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(10)
Set myNewFolder = myFolder.Folders.Add("My Contacts")
myNewFolder.MoveTo myNameSpace.GetDefaultFolder(6)


Move Method Example

This Visual Basic for Applications example uses GetDefaultFolder to return the MAPIFolder object that represents the default folder. It then uses the Find and FindNext methods to find all messages sent by Mike Nash and uses the Move method to move all mail messages sent by Mike Nash from the default Inbox folder to the Personal Mail folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myInbox.Items
Set myDestFolder = myInbox.Folders("Personal Mail")
Set myItem = myItems.Find("[SenderName] = 'Mike Nash'")
While TypeName(myItem) <> "Nothing"
    myItem.Move myDestFolder
    Set myItem = myItems.FindNext
Wend

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(6)
Set myItems = myInbox.Items
Set myDestFolder = myInbox.Folders("Personal Mail")
Set myItem = myItems.Find("[SenderName] = 'Mike Nash'")
While TypeName(myItem) <> "Nothing"
    myItem.Move myDestFolder
    Set myItem = myItems.FindNext
Wend


OnStatusChange Method Example

This Microsoft Visual Basic/Visual Basic for Applications example shows how to call the OnStatusChange method to notify Microsoft Outlook that the user has changed a value on a custom property page.

Private Sub Option1_Click()
    Dim myPPSite As Outlook.PropertyPageSite
    Set myPPSite = Parent
    globNewUserType = globAdministrator
    If globUserType <> globNewUserType Then
        globDirty = True
    End If
    myPPSite.OnStatusChange
End Sub


PublishForm Method Example

This Visual Basic for Applications example creates a contact, obtains its FormDescription object, and saves it in the Folder form registry of the default Contacts folder.

Note The PublishForm method will return an error if the caption (Name) for the form is not set first.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(olFolderContacts)
Set myItem = myOlApp.CreateItem(olContactItem)
Set myForm = myItem.FormDescription
myForm.Name = "My Contact"
myForm.PublishForm olFolderRegistry, myFolder

This Visual Basic for Applications example creates an appointment, obtains its FormDescription object, and saves it in the user's Personal form registry.

To view the form after you have published it, go to Choose Form in the File, New menu and choose Personal Forms Library in the Look In: box. You can double-click on your new form, "Interview Scheduler" in the list.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olAppointmentItem)
Set myForm = myItem.FormDescription
myForm.Name = "Interview Scheduler"
myForm.PublishForm olPersonalRegistry


RemoveMembers Method Example

This Microsoft Visual Basic/Visual Basic for Applications example locates every distribution list item in the default Contacts folder and then determines if the current user is a member of the list. If that is the case, the current user is removed from the distribution list.

Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myDistList As Outlook.DistListItem
Dim tmpRecips As Outlook.Recipients
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set tmpRecips = myOlApp.CreateItem(olMailItem).Recipients
tmpRecips.Add myNameSpace.CurrentUser.Name
Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
For x = 1 To myFolder.Items.Count
    If TypeName(myFolder.Items.Item(x)) = _
            "DistListItem" Then
        Set myDistList = myFolder.Items.Item(x)
        For y = 1 To myDistList.MemberCount
            If myDistList.GetMember(y).Name = _
                    myNameSpace.CurrentUser.Name Then
                myDistList.RemoveMembers tmpRecips
                myDistList.Save
                Exit For
            End If
        Next y
    End If
Next x

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNamespace("MAPI")
Set tmpRecips = Application.CreateItem(olMailItem).Recipients
tmpRecips.Add myNameSpace.CurrentUser.Name
Set myFolder = myNameSpace.GetDefaultFolder(10)
For x = 1 To myFolder.Items.Count
    If TypeName(myFolder.Items.Item(x)) = _
            "DistListItem" Then
        Set myDistList = myFolder.Items.Item(x)
        For y = 1 To myDistList.MemberCount
            If myDistList.GetMember(y).Name = _
                    myNameSpace.CurrentUser.Name Then
                myDistList.RemoveMembers tmpRecips
                myDistList.Save
                Exit For
            End If
        Next
    End If
Next


Remove Method Example

This Visual Basic for Applications example uses the Remove method to remove all attachments from a forwarded message before sending it on to John Y. Chen.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector.CurrentItem.Forward
Set myAttachments = myItem.Attachments
While myAttachments.Count > 0
    myAttachments.Remove 1
Wend
myItem.Recipients.Add "John Y. Chen"
myItem.Send

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myItem = Application.ActiveInspector.CurrentItem.Forward
Set myAttachments = myItem.Attachments
While myAttachments.Count > 0
    myAttachments.Remove 1
Wend
myItem.Recipients.Add "John Y. Chen"
myItem.Send


ResolveAll Method Example

This Visual Basic for Applications example uses the ResolveAll method to attempt to resolve all recipients and, if unsuccessful, displays a message box for each unresolved recipient.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myRecipients = myItem.Recipients
myRecipients.Add("Aaron Con")
myRecipients.Add("Viki Parrott")
myRecipients.Add("Jeffrey Weems")
If Not myRecipients.ResolveAll Then
    For Each myRecipient In myRecipients
        If Not myRecipient.Resolved Then
            MsgBox myRecipient.Name
        End If
     Next
End If

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(0)
Set myRecipients = myItem.Recipients
myRecipients.Add("Aaron Con")
myRecipients.Add("Viki Parrott")
myRecipients.Add("Jeffrey Weems")
If Not myRecipients.ResolveAll Then
    For Each myRecipient In myRecipients
        If Not myRecipient.Resolved Then
            MsgBox myRecipient.Name
        End If
     Next
End If


 Resolve Method Example

Resolve Method Example

This Visual Basic for Applications example uses the Resolve method to attempt to resolve a recipient and, if unsuccessful, displays the item so a user can resolve it manually.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myRecipient = myItem.Recipients.Add("Tim O'Brien")
If Not myRecipient.Resolve Then myItem.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(0)
Set myRecipient = myItem.Recipients.Add("Tim O'Brien")
If Not myRecipient.Resolve Then myItem.Display


Respond Method Example

This Visual Basic for Applications example uses the Find method to locate a MeetingItem in the user's Inbox. If there are no meeting items, the user is informed. If a meeting item is located, the GetAssociatedAppointment method is called to get the AppointmentItem and the Respond method allows acceptance.

Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
Set myMtgReq = myFolder.Items.Find("[MessageClass] = 'IPM.Schedule.Meeting.Request'")
If TypeName(myMtgReq) <> "Nothing" Then
    Set myAppt = myMtgReq.GetAssociatedAppointment(True)
    myAppt.Respond olResponseAccepted, False, True
Else
    MsgBox "You have no meeting requests."
End If

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNamespace = Application.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(6)
Set myMtgReq = myFolder.Items.Find("[MessageClass] = 'IPM.Schedule.Meeting.Request'")
If TypeName(myMtgReq) <> "Nothing" Then
    Set myAppt = myMtgReq.GetAssociatedAppointment(True)
    myAppt.Respond olResponseAccepted, False, True
Else
    MsgBox "You have no meeting requests."
End If


Restrict Method Example

This Visual Basic for Applications example uses the Restrict method to get all Inbox items dealing with Project X and moves them to the Project X folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder =  _
    myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myFolder.Items
Set myRestrictItems = myItems.Restrict _
    ("[Categories] = 'Project X'")
For Each myItem In myRestrictItems
    myItem.Move myFolder.Folders("Project X")
Next

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(6)
Set myItems = myFolder.Items
Set myRestrictItems = myItems.Restrict _
    ("[Categories] = 'Project X'")
For Each myItem In myRestrictItems
    myItem.Move myFolder.Folders("Project X")
Next

This Visual Basic for Applications example uses the Restrict method to apply a filter to the Contact items based on the item's LastModificationTime property.

Public Sub ContactDateCheck()
   Set myOlApp = CreateObject("Outlook.Application")
   Set myNameSpace = myOlApp.GetNamespace("MAPI")
   Set myContacts = myNameSpace.GetDefaultFolder(olFolderContacts).Items
   Set myItems = myContacts.Restrict("[LastModificationTime] > '05/15/97'")
   For Each myItem In myItems
       MsgBox myItem.FullName & ": " & MyItem.LastModificationTime
   Next
End Sub

The following Visual Basic for Applications example is the same as the example above, except that it demonstrates the use of a variable in the filter.

Public Sub ContactDateCheck()
   Set myOlApp = CreateObject("Outlook.Application")
   Set myNameSpace = myOlApp.GetNamespace("MAPI")
   Set myContacts = myNameSpace.GetDefaultFolder(olFolderContacts).Items
   DateStart = #6/11/97#
   DateToCheck$ = "[LastModificationTime] >= """ & DateStart & """"
   Set myRestrictItems = myContacts.Restrict(DateToCheck$)
   For Each myItem In myRestrictItems
      MsgBox myItem.FullName & ": " & MyItem.LastModificationTime
   Next
End Sub


 SaveAsFile Method Example

SaveAsFile Method Example

This Visual Basic for Applications example uses the SaveAsFile method to save the first attachment of the currently open item as a file in the My Documents folder, using the attachment's display name as the file name.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector.CurrentItem
Set myAttachments = myItem.Attachments
myAttachments.Item(1).SaveAsFile "C:\My Documents\" & _
    myAttachments.Item(1).DisplayName

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myItem = Application.ActiveInspector.CurrentItem
Set myAttachments = myItem.Attachments
myAttachments.Item(1).SaveAsFile "C:\My Documents\" & _
    myAttachments.Item(1).DisplayName


 SaveAs Method Example

SaveAs Method Example

This Visual Basic for Applications example uses the SaveAs method to save the currently open item as a text file in the My Documents folder, using the subject as the file name.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector.CurrentItem
myItem.SaveAs "C:\My Documents\" & myItem.Subject & ".txt", olTXT

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.ActiveInspector.CurrentItem
myItem.SaveAs "C:\My Documents\" & myItem.Subject & ".txt", 0


 ShowFormPage Method Example

ShowFormPage Method Example

This Visual Basic for Applications example uses the ShowFormPage method to show the All Fields page of the currently open item. If there is no currently open item, a message box will inform the user.

Set myOlApp = CreateObject("Outlook.Application")
Set myInspector = myOlApp.ActiveInspector
On Error GoTo ErrorHandler
myInspector.ShowFormPage("All Fields")
Set myItem = myInspector.CurrentItem
myItem.Display
Exit Sub
ErrorHandler:
    MsgBox "No current item to display!"


ShowPane Method Example

This Microsoft Visual Basic/Visual Basic for Applications example uses the ShowPane and IsPaneVisible methods to hide the preview pane if it is visible, or to display it if it is hidden.

Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Set myOlExp = myOlApp.ActiveExplorer
myOlExp.ShowPane olPreview, _
    Not myOlExp.IsPaneVisible(olPreview)

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myOlExp = Application.ActiveExplorer
myOlExp.ShowPane 3, Not myOlExp.IsPaneVisible(3)


Sort Method Example

The following Visual Basic for Applications example uses the Sort method to sort the Items collection for the default Contacts folder by the "CompanyName" property and then displays the company names each in turn.

Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(olFolderContacts)
Set myItems = myFolder.Items
myItems.Sort "[CompanyName]", False
For Each myItem in myItems
    MsgBox myItem.CompanyName
Next myItem

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNamespace = Application.GetNamespace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(10)
Set myItems = myFolder.Items
myItems.Sort "[CompanyName]", False
For Each myItem in myItems
    MsgBox myItem.CompanyName
Next


Start Method Example

This Microsoft Visual Basic/Visual Basic for Applications example starts synchronization of the user’s second synchronization profile in response to the user clicking a button on a form. The mySyncObj variable is declared as a public variable so it can be referenced by other modules.

Public mySyncObj As Outlook.SyncObject

Private Sub Command1_Click()
    Dim myOlApp As New Outlook.Application
    Dim mySyncs As Outlook.SyncObjects
    Set mySyncs = myOlApp.GetNamespace("MAPI").SyncObjects
    Set mySyncObj = mySyncs.Item(2)
    mySyncObj.Start
End Sub


StatusReport Method Example

This Visual Basic for Applications example uses the StatusReport method to report the status of the currently open task.

Set myOlApp = CreateObject("Outlook.Application")
Set myTask = myOlApp.ActiveInspector.CurrentItem
Set myReport = myTask.StatusReport
myReport.Send

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myTask = Application.ActiveInspector.CurrentItem
Set myReport = myTask.StatusReport
myReport.Send


Stop Method Example

This Microsoft Visual Basic/Visual Basic for Applications example interrupts synchronization of the user’s second synchronization profile in response to the user clicking a button on a form. The mySyncObj variable is declared as a public variable so it can be referenced by other modules.

Public mySyncObj As Outlook.SyncObject

Private Sub Command2_Click()
    MsgBox "Synchronization stopped by user."
    mySyncObj.Stop
End Sub


Additional Control Over Attachments

New events have been added to the Microsoft Outlook object model that let your program detect when attachments have been added to or opened in an item and when an attempt is being made to change an existing attachment.

All items that support attachments now fire the AttachmentAdd event when an attachment is added to the item. When a user opens an attachment in an item, the item fires the AttachmentRead event. If the user attempts to save an open attachment, the item fires the BeforeAttachmentSave event; the event handler can cancel the default action for this event, preventing the user from changing the attachment.


Additional Control Over the Explorer and Inspector

To make it easier to automate Microsoft Outlook 2000, the Outlook object model has been extended with a number of new objects, properties, events, and methods to give programs greater control over the Outlook user interface.

The Explorers and Inspectors collection objects give you access to any explorer or inspector window, while the NewExplorer and NewInspector events notify your program that a new explorer or inspector window has been opened.

New properties, methods, and events have been added to the Explorer and Inspector objects to let your program have greater control over the Outlook user interface.

You can control the Outlook Bar in the explorer window through new objects added to the Outlook object model. Using these objects and their properties, methods, and events, you can add groups and shortcuts to the Outlook Bar and remove them, and you can limit the user’s ability to navigate using the Outlook Bar.

Outlook also allows you to add custom property pages to the Outlook Options dialog box (available through the Tools menu of the explorer and inspector) and the folders Properties dialog box.


Application-Level Events

Previous versions of Microsoft Outlook provided event notifications only for individual items. Outlook 2000 has added a wide range of events that your program can use to detect changes in Outlook windows or the message store. This gives your program greater control over Outlook and makes it easier to automate Outlook from an external application or through an add-in program.

Your program can detect when new mail has been delivered or when an item has been added to, removed from, or changed in a folder; when an item has been sent; when a reminder has fired; when an explorer or inspector window has been displayed, activated, or deactivated; when the user has switched views or folders within an explorer; when the Outlook Bar has been modified; and so on. In some cases, your program can cancel the event, preventing Outlook from performing the default action for the event.

The following new events have been added to Outlook.

Event | Description
Activate | Notifies your program that an explorer or inspector window has become the active window.
BeforeFolderSwitch | Notifies your program that the user has attempted to change the folder displayed by an explorer. Your program can cancel the event to prevent the change.
BeforeGroupAdd | Notifies your program that the user has attempted to add a group to the Outlook Bar. Your program can cancel the event to prevent the change.
BeforeGroupRemove | Notifies your program that the user has attempted to remove a group from the Outlook Bar. Your program can cancel the event to prevent the change.
BeforeGroupSwitch | Notifies your program that the user has attempted to change the group displayed in the Outlook Bar. Your program can cancel the event to prevent the change.
BeforeShortcutAdd | Notifies your program that the user has attempted to add a shortcut to the Outlook Bar. Your program can cancel the event to prevent the change.
BeforeShortcutRemove | Notifies your program that the user has attempted to remove a shortcut from the Outlook Bar. Your program can cancel the event to prevent the change.
BeforeViewSwitch | Notifies your program that the user has attempted to change the view used to display the contents of a folder in an explorer window. Your program can cancel the event to prevent the change.
Deactivate | Notifies your program that an explorer or inspector window is no longer the active window.
FolderAdd | Notifies your program that a folder has been added to a specific folders collection.
FolderChange | Notifies your program that a folder in a specific folders collection has been changed.
FolderRemove | Notifies your program that a folder has been deleted from a specific folders collection.
FolderSwitch | Notifies your program that the user has changed the folder displayed by an explorer window.
GroupAdd | Notifies your program that a group has been added to the Outlook Bar.
ItemAdd | Notifies your program that an item has been added to a specific items collection.
ItemChange | Notifies your program that an item in a specific items collection has been changed.
ItemRemove | Notifies your program that an item has been deleted from a specific items collection.
ItemSend | Notifies your program that the user has attempted to send an item. Your program can cancel the event to prevent the item from being sent.
NewExplorer | Notifies your program that a new explorer window has been created.
NewInspector | Notifies your program that a new inspector window has been created.
NewMail | Notifies your program that new items have been delivered to the Inbox.
OnError | Notifies your program that an error occurred during folder synchronization.
OptionsPagesAdd | Notifies your program that new options pages have been added to a property or options dialog box.
Progress | Notifies your program of the status of folder synchronization.
Reminder | Notifies your program that a reminder is about to be displayed.
SelectionChange | Notifies your program that the selection of items in an explorer window has changed.
ShortcutAdd | Notifies your program that a shortcut has been added to the Outlook Bar.
SyncStart | Notifies your program that Outlook has begun synchronizing the user’s folders.
SyncEnd | Notifies your program that Outlook has finished synchronizing the user’s folders
ViewSwitch | Notifies your program that the view used to display the contents of a folder in an explorer window has changed.


Outlook COM add-in template

The following code example provides the empty event procedures required to implement a COM add-in.

Implements IDTExtensibility2

Private Sub IDTExtensibility2_OnAddInsUpdate(custom() As Variant)
' Occurs when the set of connected COM add-ins changes, that is when
' any other add-in is connected or disconnected.
' The custom argument is ignored.
End Sub

Private Sub IDTExtensibility2_OnBeginShutdown(custom() As Variant)
' If the COM add-in is connected, occurs when Outlook begins its
' shutdown routines.
' The custom argument is ignored.

End Sub

Private Sub IDTExtensibility2_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
' Occurs when the COM add-in is connected.
' The Application argument is the Outlook Application object.
' The ConnectMode argument specifies how the COM add-in was connected.
' It can be
'     ext_cm_AfterStartup     Add-in was connected after Outlook started,
'                             or the Connect property of the corresponding
'                             COMAddIn object was set to True
'     ext_cm_Startup          Add-in was connected on startup
' The AddInInst argument is the COMAddIn object that refers to the current
'     instance of the add-in itself.
' The custom argument is ignored.
End Sub

Private Sub IDTExtensibility2_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
' Occurs when the COM add-in is disconnected.
' The RemoveMode argument specifies how the COM add-in was disconnected.
' It can be
'     ext_dm_HostShutdown      Add-in was disconnected when Outlook was
'                              closed.
'     ext_dm_UserClosed        Add-in was disconnected when the user
'                              cleared the corresponding check box in the
'                              COM Add-ins dialog box, or the Connect
'                              property of the corresponding COMAddIn
'                              object was set to False.
' The custom argument is ignored.
End Sub

Private Sub IDTExtensibility2_OnStartupComplete(custom() As Variant)
' If the COM add-in connects at startup, occurs when Outlook completes
' its startup routines. This event does not occur if the COM add-in is not
' connected when Outlook loads, even when the user connects the add-in in
' the COM Add-ins dialog box.
' The custom argument is ignored.
End Sub


Support for COM Add-ins

Along with other Microsoft Office 2000 applications, Microsoft Outlook 2000 allows you to enhance and extend the application using Component Object Model (COM) add-ins. A COM add-in is a dynamic-link library (DLL) that’s specially registered so that it can be loaded by an Office 2000 application. You can build a COM add-in with Microsoft Visual Basic version 5.0 or later, or any of the Office 2000 applications in the Office 2000 Developer. You can also create COM add-ins with Microsoft Visual C++ or Microsoft Visual J++.

The COMAddIns property of the Application object gives you access to the COM add-ins loaded by Outlook.

Learn more about customizing Outlook using COM add-ins.


Support for Contact Linking

Microsoft Outlook 2000 allows users to establish links between contact items and other items. The Outlook object model has been extended to give programs access to these links. All Outlook item objects have an associated Links collection object that contains the contacts to which a particular item is linked. You can use standard collection methods and properties (Add, Count, Item, and Remove) to create, access, and remove items from the collection.


Support for Custom Property Pages

You can create your own property pages to customize the Microsoft Outlook Options dialog box (available through the Tools menu of the explorer and inspector windows) and the Properties dialog box for all folders.

A custom property page is an ActiveX control stored in a dynamic-link library (DLL) that implements the PropertyPage object and that’s installed as a COM add-in. This object provides the interface through which Outlook can query the property page about its status and inform the property page that the user has clicked the Apply or OK button.

Learn about adding custom property pages.


Support for Folder Synchronization

Users who travel with their computers or who otherwise need to use Microsoft Outlook when disconnected from the network need to be able to synchronize their offline folders using different criteria, depending on the situation. For example, before departing on a trip, a user might synchronize all of her offline folders, plus the Address Book. When she arrives at her destination, she connects to her home office using a modem. Because of the slow data-transfer rate, she only wants to synchronize her inbox and outbox to receive and send messages.

Outlook 2000 supports multiple synchronization profiles so users can select how they want Outlook to synchronize offline folders in a given situation. The new SyncObjects collection object represents all the synchronization profiles for a given user. Your program can use the Start and Stop methods of the SyncObject objects in this collection to begin and end synchronization using a particular profile, and can monitor the progress of the synchronization using the SyncStart, Progress, OnError, and SyncEnd events.


Visual Basic for Applications Hosted by Outlook

Microsoft Outlook 2000 gives you the ability to write macros to control Outlook using Visual Basic for Applications. You use the same Visual Basic Editor that’s available to other Microsoft Office 2000 applications, giving you a powerful, yet easy-to-use environment in which to customize and extend Outlook.

Visual Basic for Applications macros are the ideal solution when you want to customize Outlook but don't need to develop custom forms. You can easily create a toolbar button that runs a macro by using the new toolbar-customization features of Outlook 2000.


Application Property Example

This Visual Basic for Applications example uses the Application property to access Outlook and then creates a new MailItem and displays it.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = = myOlApp.CreateItem(olMailItem)
myItem.Display

If you use VBScript, you do not use the Application property to retrieve the Application object. Instead, you reference the Application object directly. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(0)
myItem.Display


 Body Property Example

Body Property Example

This VBScript example uses the Open event of an item to set its Body property.

Function Item_Open()
    Item.Body = "This is the message body."
End Function


Color Property Example

This example creates a new NoteItem and sets the color to blue.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olNoteItem)
myItem.Color = olBlue

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(5)
myItem.Color = 0


COMAddIns Property Example

This Microsoft Visual Basic example displays the number of COM add-ins currently connected.

Dim myOlApp As New Outlook.Application
Private Sub Command1_Click()
    MsgBox "There are " & _
        myOlApp.COMAddIns.Count & " COM add-ins."
End Sub

If you use VBScript, you do not declare an Application object variable. This example shows how to perform the same task using VBScript.

Sub Commandbutton1_Click()
    MsgBox "There are " & _
       Application.COMAddIns.Count & " COM add-ins."
End Sub


Contents Property Example

This Microsoft Visual Basic/Visual Basic for Applications example displays a message listing the groups in the Outlook Bar.

Dim myOlApp As New Outlook.Application
Dim myOlBar As Outlook.OutlookBarPane
Dim myOlGroups As Outlook.OutlookBarGroups
myMsg = "The groups in the Outlook Bar are:"
Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
Set myOlGroups = myOlBar.Contents.Groups
For x = 1 To myOlGroups.Count
    myMsg = myMsg & Chr(13) & myOlGroups.Item(x)
Next x
MsgBox myMsg

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

myMsg = "The groups in the Outlook Bar are:"
Set myOlBar = Application.ActiveExplorer.Panes.Item("OutlookBar")
Set myOlGroups = myOlBar.Contents.Groups
For x = 1 To myOlGroups.Count
    myMsg = myMsg & Chr(13) & myOlGroups.Item(x)
Next
MsgBox myMsg


CurrentFolder Property Example

This Visual Basic for Applications example uses the CurrentFolder property to change the displayed folder to the user's Calendar folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myOlApp.ActiveExplorer.CurrentFolder = _
    myNameSpace.GetDefaultFolder(olFolderCalendar)

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set Application.ActiveExplorer.CurrentFolder = _
    myNameSpace.GetDefaultFolder(9)


CurrentGroup Property Example

The following example opens the Outlook Bar group named My Shortcuts.

Dim myOlApp As New Outlook.Application
Dim myOlBar As Outlook.OutlookBarPane
Dim myOlGroup As Outlook.OutlookBarGroup
Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
Set myOlGroup = myOlBar.Contents.Groups.Item("My Shortcuts")
Set myOlBar.CurrentGroup = myOlGroup

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myOlBar = Application.ActiveExplorer.Panes.Item("OutlookBar")
Set myOlGroup = myOlBar.Contents.Groups.Item("My Shortcuts")
Set myOlBar.CurrentGroup = myOlGroup


 CurrentItem Property Example

CurrentItem Property Example

This Visual Basic for Applications example uses the CurrentItem property to obtain the current item that the user is viewing. If there is no currently open item, an error will be returned.

Set myOlApp = CreateObject("Outlook.Application")
On Error Resume Next
Set myItem = myOlApp.ActiveInspector.CurrentItem


CurrentUser Property Example

This Visual Basic for Applications example uses the CurrentUser property to obtain the name of the currently logged-on user and then displays a message box containing the name.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
MsgBox myNameSpace.CurrentUser.Name

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
MsgBox myNameSpace.CurrentUser.Name


CurrentView Property Example

The following example sets the current view in the active explorer to Messages.

Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Set myOlExp = myOlApp.ActiveExplorer
myOlExp.CurrentView = "Messages"

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Application.ActiveExplorer.CurrentView = "Messages"


Dirty Property Example

This Visual Basic/Visual Basic for Applications example returns the value of the Dirty property as the value of a global variable.

Private Property Get PropertyPage_Dirty() As Boolean
    PropertyPage_Dirty = globDirty
End Property


DLName Property Example

This Microsoft Visual Basic/Visual Basic for Applications example creates a new distribution list and then prompts the user for the name.

Dim myOlApp As New Outlook.Application
Dim myDistList As Outlook.DistListItem
Set myDistList = myOlApp.CreateItem(olDistributionListItem)
myDistList.DLName = InputBox("Type the name of the new distribution list.")
myDistList.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myDistList = Application.CreateItem(7)
myDistList.DLName = _
    InputBox("Type the name of the new distribution list.")
myDistList.Display


Email1AddressType Property Example

This Visual Basic for Applications example sets "SMTP" as the address type for the first e-mail entry of a contact.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)
myItem.Email1AddressType = "SMTP"

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(2)
myItem.Email1AddressType = "SMTP"


Email1Address Property Example

This Visual Basic for Applications example sets "Jsmith@msn.com" as the e-mail address for the first e-mail entry of a contact.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)
myItem.Email1Address = "someone@microsoft.com"

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(2)
myItem.Email1Address = "someone@microsoft.com"


Email2AddressType Property Example

This Visual Basic for Applications example sets "SMTP" as the address type for the second e-mail entry of a contact.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)
myItem.Email2AddressType = "SMTP"

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(2)
myItem.Email2AddressType = "SMTP"


Email2Address Property Example

This Visual Basic for Applications example sets "Jsmith@msn.com" as the e-mail address for the second e-mail entry of a contact.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)
myItem.Email2Address = "someone@microsoft.com"

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(2)
myItem.Email2Address = "someone@microsoft.com"


Email3AddressType Property Example

This Visual Basic for Applications example sets "SMTP" as the address type for the third e-mail entry of a contact.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)
myItem.Email3AddressType = "SMTP"

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(2)
myItem.Email3AddressType = "SMTP"


Email3Address Property Example

This Visual Basic for Applications example sets "Jsmith@msn.com" as the e-mail address for the third e-mail entry of a contact.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olContactItem)
myItem.Email3Address = " someone@microsoft.com "

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(2)
myItem.Email3Address = "someone@microsoft.com"


EntryID Property Example

This Visual Basic for Applications example uses the EntryID property to compare the entry ID of one message to the entry ID of a message returned by a search operation to determine whether the objects represent the same message.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myContacts = myNameSpace.GetDefaultFolder (olFolderContacts)
Set myItem1 = myOlApp.CreateItem(olContactItem)
myItem1.FirstName = "Brent"
Set myItem2 = myContacts.Items.Find("[FileAs] = _
    ""Jones"" and [FirstName] = ""Brent""")
If myItem1.EntryID = myItem2.EntryID Then
    MsgBox "These two message objects refer to the same message."
End If


Explorers Property Example

The following Microsoft Visual Basic example displays the number of explorer windows that are open.

Dim myOlApp As New Outlook.Application
Private Sub Command1_Click()
    MsgBox "There are " & _
         myOlApp.Explorers.Count & " Explorers."
End Sub

If you use VBScript, you do not declare an Application object variable. This example shows how to perform the same task using VBScript.

Sub CommandButton1_Click()
    MsgBox "There are " & _
        Application.Explorers.Count & " Explorers."
End Sub


FreeBusy Method Example

This Visual Basic for Applications example uses the FreeBusy method to return a string of free/busy information with one character for each day. This example allows for the possibility that the free/busy information for this recipient is not accessible.

Public Sub cmdCreate_Click()
    Set myOlApp = CreateObject("Outlook.Application")
    Set myNameSpace = myOlApp.GetNameSpace("MAPI")
    Set myRecipient = myNameSpace.CreateRecipient("Paul Borm")
    On Error GoTo ErrorHandler
    myFBInfo = myRecipient.FreeBusy(#8/1/97#, 60 * 24)
    Exit Sub
    ErrorHandler: MsgBox "Cannot access information. "
End Sub

This Visual Basic for Applications example returns a string of free/busy information with one character for each hour (complete format).

Set myRecipient = myNameSpace.CreateRecipient("Kevin Yim")
myFBInfo = myRecipient.FreeBusy(#8/1/97#, 60, True)


GetInspector Property Example

This Visual Basic for Applications example uses the GetInspector property to return a new, inactive inspector for myItem, and then displays it.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
Set myInspector = myItem.GetInspector
myInspector.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(0)
Set myInspector = myItem.GetInspector
myInspector.Display


Groups Property Example

The following Microsoft Visual Basic/Visual Basic for Applications example displays the number of groups in the Outlook Bar.

Dim myOlApp As New Outlook.Application
Dim myOlBar As Outlook.OutlookBarPane
Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
myCount = myOlBar.Contents.Groups.Count
MsgBox "There are " & myCount & " groups in the Outlook Bar"

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myOlBar = Application.ActiveExplorer.Panes.Item("OutlookBar")
myCount = myOlBar.Contents.Groups.Count
MsgBox "There are " & myCount & " groups in the Outlook Bar"


HelpContextID Property

Associates a specific topic in a custom Microsoft Windows Help file with a specific control.

Syntax

object.HelpContextID [= Long]

The HelpContextID property syntax has these parts:

Part | Description
object | Required. A valid object.
Long | Optional. A positive integer that specifies the context ID of a topic in the Help file associated with the object. Zero indicates that no Help topic is associated with the object (default). Must be a valid context ID in the specified Help file.


 HTMLBody Property Example

HTMLBody Property Example

This VBScript example uses the Open event to access the HTMLBody property of an item. This sets the EditorType property of the item’s Inspector to olEditorHTML(2). When the item's Body property is set, the EditorType property is changed to the default. For example, if the default editor is set to RTF, the EditorType is set to olEditorRTF(3).

If this code is placed in the Script Editor of a form in design mode, the message boxes during run time will reflect the change in the EditorType as the body of the form changes. The final message box utilizes the ScriptText property to display all the VBScript code in the Script Editor.

Function Item_Open()
    'Set the HTMLBody of the item.
    Item.HTMLBody = "<HTML><H2>My HTML page.</H2><BODY>My body.</BODY></HTML>"
    'Item displays HTML message.
    Item.Display
    'MsgBox shows EditorType is 2.
    MsgBox "HTMLBody EditorType is " & Item.GetInspector.EditorType
    'Access the Body and show
    'the text of the Body.
    MsgBox "This is the Body: " & Item.Body
    'After accessing, EditorType
    'is still 2.
    MsgBox "After accessing, the EditorType is " & Item.GetInspector.EditorType
    'Set the item's Body property.
    Item.Body = "Back to default body."
    'After setting, EditorType is
    'now back to the default.
    MsgBox "After setting, the EditorType is " & Item.GetInspector.EditorType
    'Access the items's
    'FormDescription object.
    Set myForm = Item.FormDescription
    'Display all the code
    'in the Script Editor.
    MsgBox myForm.ScriptText
End Function


HTMLEditor Property Example

The following VBScript example uses the Click event of a CommandButton named "CommandButton1" to demonstrate the listing of all HTML elements.

Sub CommandButton1_Click()
    Dim i         'As Integer
    Dim strHTMLType    'As String
    Dim strHTMLText    'As String
    Dim NL        'As String

    NL = chr(10) & chr(13)

    Set myInspector = Item.GetInspector
    Set myIExplorer = myInspector.HTMLEditor
    If myIExplorer.ReadyState <> "complete" Then
'Test for complete loading of HTML doc
        For i = 0 To myIExplorer.All.Length - 1
            strHTMLType = TypeName(myIExplorer.All.Item(i))
            On Error Resume Next
'because not all elements support OuterHTML
            strHTMLText = ": " & NL &     myIExplorer.All.Item(i).outerHTML
            On Error GoTo 0
            MsgBox strHTMLType & strHTMLText
            strHTMLText = ""
        Next
    End If
End Sub


IncludeRecurrences Property Example

This Visual Basic for Applications example uses IncludeRecurrences to demonstrate how to return a specific instance of a recurring appointment. In this example, the fifth occurrence of the series of appointments with the subject "Weekly Meeting" will be returned.

Set myOlApp = CreateObject("Outlook.Application")
Set myItems = myOlApp.ActiveExplorer.CurrentFolder.Items
Set myItems = myItems.Restrict("[Subject] = 'Weekly Meeting'")
myItems.Sort "[Start]"
myItems.IncludeRecurrences = True
MsgBox "The fifth instance of the recurring appointment _
    occurs on:" & myItems.Item(5).Start


Inspectors Property Example

This Microsoft Visual Basic example uses the Inspectors property and the Count property and Item method of the Inspectors object to display the captions of all inspector windows.

Dim myOlApp As New Outlook.Application
Private Sub Command1_Click()
    If myOlApp.Inspectors.Count > 0 Then
        For x = 0 To myOlApp.Inspectors.Count - 1
            MsgBox Inspectors.Item(x).Caption
        Next x
    Else
        MsgBox "There are no inspector windows open."
    End If
End Sub

If you use VBScript, you do not declare an Application object variable. This example shows how to perform the same task using VBScript.

Sub Commandbutton1_Click()
    If Application.Inspectors.Count > 0 Then
        For x = 0 To Application.Inspectors.Count - 1
            MsgBox Application.Inspectors.Item(x).Caption
        Next
    Else
        MsgBox "There are no inspector windows open."
    End If
End Sub


Interval Property Example

This Visual Basic for Applications example uses GetRecurrencePattern to obtain the RecurrencePattern object for the newly-created AppointmentItem. The properties, RecurrenceType, DayOfWeekMask, PatternStartDate, Interval, PatternEndDate, and Subject are set, the appointment is saved and then displayed with the pattern: "Occurs every 3 week(s) on Monday effective 1/21/98 until 10/5/09 from 2:30 PM to 3:00 PM."

Set myOlApp = New Outlook.Application
Set myApptItem = myOlApp.CreateItem(olAppointmentItem)
Set myRecurrPatt = myApptItem.GetRecurrencePattern

myRecurrPatt.RecurrenceType = olRecursWeekly
myRecurrPatt.DayOfWeekMask = olMonday
myRecurrPatt.PatternStartDate = #1/21/98 2:00:00 PM#
myRecurrPatt.Interval = 3
myRecurrPatt.PatternEndDate = #12/21/2001 5:00:00 PM#
myApptItem.Subject = "Important Appointment"
myApptItem.Save
myApptItem.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myApptItem = Application.CreateItem(1)
Set myRecurrPatt = myApptItem.GetRecurrencePattern
myRecurrPatt.RecurrenceType = 1
myRecurrPatt.DayOfWeekMask = 2
myRecurrPatt.PatternStartDate = #1/21/98 2:00:00 PM#
myRecurrPatt.Interval = 3
myRecurrPatt.PatternEndDate = #12/21/2001 5:00:00 PM#
myApptItem.Subject = "Important Appointment"
myApptItem.Save
myApptItem.Display


 Items Property Example

Items Property Example

This Visual Basic for Applications example uses the Items property to obtain the collection of MailItem objects from the default Inbox folder.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myFolder.Items

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(6)
Set myItems = myFolder.Items


Links Property Example

This Microsoft Visual Basic/Visual Basic for Applications example steps through the items in the Tasks folder and, if a task is not complete, displays the number of contacts linked to the item.

Dim myOlApp As New Outlook.Application
Dim myNSpace As Outlook.NameSpace
Dim myItems As Outlook.Items
Dim myItem As Outlook.TaskItem
Dim myLinks As Outlook.Links
Dim myLink As Outlook.Link
Set myNSpace = myOlApp.GetNamespace("MAPI")
Set myItems = myNSpace.GetDefaultFolder(olFolderTasks).Items
For x = 1 To myItems.Count
    If TypeName(myItems.Item(x)) = "TaskItem" Then
        Set myItem = myItems.Item(x)
        Set myLinks = myItem.Links
        Msg = myItem.Subject & " has " & myLinks.Count & " links."
        If myItem.Complete = False Then
            If MsgBox(Msg, vbOKCancel) = vbCancel Then Exit For
        End If
    End If
 Next x

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNSpace = Application.GetNamespace("MAPI")
Set myItems = myNSpace.GetDefaultFolder(13).Items
For x = 1 To myItems.Count
    If TypeName(myItems.Item(x)) = "TaskItem" Then
        Set myItem = myItems.Item(x)
        Set myLinks = myItem.Links
        Msg = myItem.Subject & " has " & myLinks.Count & " links."
        If myItem.Complete = False Then
            If MsgBox(Msg, 1) = 2 Then Exit For
        End If
    End If
 Next


MeetingStatus Property Example

This Visual Basic for Applications example uses CreateItem to create an appointment and uses MeetingStatus to set the meeting status to "Meeting" to turn it into a meeting request with both a required and an optional attendee.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olAppointmentItem)
myItem.MeetingStatus = olMeeting
myItem.Subject = "Strategy Meeting"
myItem.Location = "Conference Room B"
myItem.Start = #9/24/97 1:30:00 PM#
myItem.Duration = 90
Set myRequiredAttendee = myItem.Recipients.Add ("Nate Sun")
myRequiredAttendee.Type = olRequired
Set myOptionalAttendee = myItem.Recipients.Add ("Kevin Kennedy")
myOptionalAttendee.Type = olOptional
Set myResourceAttendee = myItem.Recipients.Add("Conference Room B")
myResourceAttendee.Type = olResource
myItem.Send

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(1)
myItem.MeetingStatus = 1
myItem.Subject = "Strategy Meeting"
myItem.Location = "Conference Room B"
myItem.Start = #9/24/97 1:30:00 PM#
myItem.Duration = 90
Set myRequiredAttendee = myItem.Recipients.Add ("Nate Sun")
myRequiredAttendee.Type = 1
Set myOptionalAttendee = myItem.Recipients.Add ("Kevin Kennedy")
myOptionalAttendee.Type = 2
Set myResourceAttendee = myItem.Recipients.Add("Conference Room B")
myResourceAttendee.Type = 3
myItem.Send


MemberCount Property Example

This Microsoft Visual Basic/Visual Basic for Applications example steps through the default Contacts folder, and if it finds a distribution list with more than 20 members it displays the item.

Dim myOlApp As New Outlook.Application
Dim myOlFolder As Outlook.MAPIFolder
Dim myOlItems As Outlook.Items
Dim myOlDistList As Outlook.DistListItem
Set myOlFolder = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
Set myOlItems = myOlFolder.Items
For x = 1 To myOlItems.Count
    If TypeName(myOlItems.Item(x)) = "DistListItem" Then
        Set myOlDistList = myOlItems.Item(x)
        If myOlDistList.MemberCount > 20 Then
            MsgBox myOlDistList.DLName & " has more than 20 members."
            myOlDistList.Display
        End If
    End If
Next x

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myOlFolder = _
    Application.GetNamespace("MAPI").GetDefaultFolder(10)
Set myOlItems = myOlFolder.Items
For x = 1 To myOlItems.Count
    If TypeName(myOlItems.Item(x)) = "DistListItem" Then
        Set myOlDistList = myOlItems.Item(x)
        If myOlDistList.MemberCount > 20 Then
            MsgBox myOlDistList.DLName & _
                " has more than 20 members."
            myOlDistList.Display
        End If
    End If
Next


Members Property Example

This Visual Basic for Applications example uses the Members property of an AddressEntry object to display all the members in an e-mail alias in the Global Address List named "My Group". To access the Members property, the DisplayType of the AddressEntry must be a distribution list.

To use this example, substitute the name of an e-mail alias for which you would like to view the members.

Sub DisplayMembersOfAlias()
    Set myOlApp = CreateObject("Outlook.Application")
    Set myNameSpace = myOlApp.GetNameSpace("MAPI")
    'Set myAddressList to
    'the Global Address List
    'within the AddressLists
    'collection.
    Set myAddressList = myNameSpace.AddressLists("Global Address List")
    'Set myAddressEntry
    'to the entry in the
    'AddressEntries
    'collection named
    '"My Group" which is
    'a distribution list.
    Set myAddressEntry = myAddressList.AddressEntries("My Group")
    'Display each member in the
    'alias.
    For Each memberEntry In myAddressEntry.Members
      MsgBox memberEntry
    Next
End Sub


Panes Property Example

This Microsoft Visual Basic/Visual Basic for Applications example adds a group named Marketing as the second group in the Outlook Bar.

Dim myOlApp As New Outlook.Application
Dim myolBar As Outlook.OutlookBarPane
Set myolBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
myolBar.Contents.Groups.Add "Marketing", 2

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myolBar = Application.ActiveExplorer.Panes.Item("OutlookBar")
myolBar.Contents.Groups.Add "Marketing", 2


Regenerate Property Example

This Visual Basic for Applications example creates a task called "Oil Change" that recurs every three months and uses the Regenerate property to set it to regenerate after each recurrence.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olTaskItem)
Set myPattern = myItem.GetRecurrencePattern
myPattern.RecurrenceType = olRecursMonthly
myPattern.Regenerate = True
myPattern.Interval = 3
myItem.Subject = "Oil Change"
myItem.Save
myItem.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myItem = Application.CreateItem(3)
Set myPattern = myItem.GetRecurrencePattern
myPattern.RecurrenceType = 2
myPattern.Regenerate = True
myPattern.Interval = 3
myItem.Subject = "Oil Change"
myItem.Save
myItem.Display


Selection Property Example

The following Microsoft Visual Basic/Visual Basic for Applications example uses the Count property and Item method of the Selection collection returned by the Selection property to display the senders of all messages selected in the active explorer window.

Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim MsgTxt As String
MsgTxt = "You have selected items from" & Chr(13) & Chr(13)
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
For x = 1 To myOlSel.Count
    MsgTxt = MsgTxt & myOlSel.Item(x).SenderName & Chr(13)
Next x
MsgBox MsgTxt

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

MsgTxt = "You have selected items from" & Chr(13) & Chr(13)
Set myOlSel = Application.ActiveExplorer.Selection
For x = 1 To myOlSel.Count
    MsgTxt = MsgTxt & myOlSel.Item(x).SenderName & Chr(13)
Next
MsgBox MsgTxt


Shortcuts Property Example

This Microsoft Visual Basic/Visual Basic for Applications example deletes all empty groups in the Outlook Bar.

Dim myOlApp As New Outlook.Application
Dim myOlBar As Outlook.OutlookBarPane
Dim myOlGroup As Outlook.OutlookBarGroup
Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
For x = myOlBar.Contents.Groups.Count To 1 Step -1
    Set myOlGroup = myOlBar.Contents.Groups.Item(x)
    If myOlGroup.Shortcuts.Count = 0 Then
        myOlBar.Contents.Groups.Remove x
    End If
Next x

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myOlBar = Application.ActiveExplorer.Panes.Item("OutlookBar")
For x = myOlBar.Contents.Groups.Count To 1 Step -1
    Set myOlGroup = myOlBar.Contents.Groups.Item(x)
    If myOlGroup.Shortcuts.Count = 0 Then
        myOlBar.Contents.Groups.Remove x
    End If
Next


SyncObjects Property Example

This Microsoft Visual Basic/Visual Basic for Applications example starts synchronization of the user’s second synchronization profile in response to the user clicking a button on a form.

Private Sub Command1_Click()
    Dim myOlApp As New Outlook.Application
    Dim mySyncs As Outlook.SyncObjects
    Set mySyncs = myOlApp.GetNamespace("MAPI").SyncObjects
    Set mySyncObj = mySyncs.Item(2)
    mySyncObj.Start
End Sub


Target Property Example

This Microsoft Visual Basic/Visual Basic for Applications example steps through the shortcuts in the first Outlook Bar group. If it finds a shortcut that is not an Outlook folder, it deletes it.

Dim myOlApp As New Outlook.Application
Dim myOlBar As Outlook.OutlookBarPane
Dim myolGroup As Outlook.OutlookBarGroup
Dim myOlShortcuts As Outlook.OutlookBarShortcuts
Dim myOlShortcut As Outlook.OutlookBarShortcut
Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
Set myolGroup = myOlBar.Contents.Groups.Item(1)
Set myOlShortcuts = myolGroup.Shortcuts
myTop = myOlShortcuts.Count
For x = myTop To 1 Step -1
    Set myOlShortcut = myOlShortcuts.Item(x)
    If TypeName(myOlShortcut.Target) <> "MAPIFolder" Then
        myOlShortcuts.Remove x
    End If
Next x

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myOlBar = _
    Application.ActiveExplorer.Panes.Item("OutlookBar")
Set myolGroup = myOlBar.Contents.Groups.Item(1)
Set myOlShortcuts = myolGroup.Shortcuts
myTop = myOlShortcuts.Count
For x = myTop To 1 Step -1
    Set myOlShortcut = myOlShortcuts.Item(x)
    If TypeName(myOlShortcut.Target) <> "MAPIFolder" Then
        myOlShortcuts.Remove x
    End If
Next


ViewType Property Example

The following Microsoft Visual Basic/Visual Basic for Applications example toggles the first Outlook Bar group between the large and small icon views.

Dim myOlApp As New Outlook.Application
Dim myOlBar As Outlook.OutlookBarPane
Dim myOlGroup As Outlook.OutlookBarGroup
Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
Set myOlGroup = myOlBar.Contents.Groups.Item(1)
If myOlGroup.ViewType = olLargeIcon Then
    myOlGroup.ViewType = olSmallIcon
Else
    myOlGroup.ViewType = olLargeIcon
End If

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myOlBar = Application.ActiveExplorer.Panes.Item("OutlookBar")
Set myOlGroup = myOlBar.Contents.Groups.Item(1)
If myOlGroup.ViewType = 0 Then
    myOlGroup.ViewType = 1
Else
    myOlGroup.ViewType = 0
End If


Visible Property Example

This Microsoft Visual Basic/Visual Basic for Applications example toggles the visible state of the Outlook Bar.

Dim myOlApp As New Outlook.Application
Dim myOlBar As Outlook.OutlookBarPane
Set myOlBar = myOlApp.ActiveExplorer.Panes.Item("OutlookBar")
myOlBar.Visible = Not myOlBar.Visible

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myOlBar = Application.ActiveExplorer.Panes.Item("OutlookBar")
myOlBar.Visible = Not myOlBar.Visible


WindowState Property Example

This Microsoft Visual Basic/Visual Basic for Applications example minimizes all open explorer windows. It uses the Count property and Item method of the Explorers collection to enumerate the open explorer windows.

Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlExps As Outlook.Explorers
Set myOlExps = myOlApp.Explorers
For x = 1 To myOlExps.Count
    myOlExps.Item(x).WindowState = olMinimized
Next x

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

For x = 1 To Application.Explorers.Count
    Application.Explorers.Item(x).WindowState = 2
Next


WordEditor Property Example

The following VBScript example demonstrates the use of Word's object model. It adds a filled rectangle to the message area of the item.

Sub CommandButton1_Click()
    Set myInspector = Item.GetInspector
    Set WordDoc = myInspector.WordEditor
    Set Fill = WordDoc.Shapes.AddShape(1, 90, 90, 90, 50).Fill   'msoShapeRectangle=1
    Fill.ForeColor.RGB = RGB(128, 0, 0)
    Fill.BackColor.RGB = RGB(170, 170, 170)
    Fill.TwoColorGradient 4, 1   'msoGradientDiagonalDown=4
End Sub


An incorrect version of a form is being used

You probably published this form to more than one forms library. Make sure that the form is published in only one place. For more information on where to publish forms, see Save a form in a forms library.


Error: A field on this form requires a value

Check whether controls on the form have field validation enabled in the Properties dialog box of the control.

If the error still appears, you must delete any unused custom fields that exist in the item, regardless of whether they appear on the form.


I cannot open a password-protected form

Remember that the password is case-sensitive.

If a form has been password-protected and the password is no longer known, Microsoft cannot help you circumvent the password protection.


I can't change the default mail message form

You cannot set a custom form as the default form for the Inbox. All incoming mail uses the default mail form or a form specified by the sender.


I can't find the message or notes property for an item

The Message or Notes field on a form is referred to as the Body property in the Outlook object model.


My data is not being saved with the form

You probably used the Control Toolbox to add controls to a form. When you add controls from the Control Toolbox, if the control will be used to store data, you should bind the control to a field. Data is stored in fields, not controls. If a control is not bound to a field, the data will be lost when the item is saved or sent.

Note If you drag a field from the Field Chooser, the control that is created will automatically be bound to the field.


 My program sets the Message control to read-only, but it still can be changed

My program sets the Message control to read-only, but it still can be changed

Changing the ReadOnly property of a Message control at run time using Microsoft Visual Basic has no effect on whether the contents of the control can be changed by the user. The ReadOnly property is effective only when set at design time.


 My solution doesn't run on other computers

My solution doesn't run on other computers

Use the following troubleshooting tips to help troubleshoot problems if your forms or programming solution works on some computers, but not others.

VBScript version: If your solution involves forms that use VBScript, you may need to make sure that all computers are using the same version of VBScript that is being used on your development computer. VBScript is a shared component. Installing other software, such as a newer version of Microsoft Internet Explorer, may result in newer versions of VBScript being installed. Check http://www.microsoft.com/scripting for the latest information about VBScript versions.

Controls: If your solution uses any nonstandard controls, check to see if the controls are properly installed on all of the user's computers. If you are using any control other than one of the Forms 2.0 controls that are installed by Microsoft Office, you should provide to your users a setup program to ensure all of your controls are installed correctly. Both Microsoft Visual Basic and Microsoft Office 2000 Developer include tools to create custom setup programs.

Permissions or user rights: Make sure that any user experiencing problems has proper permissions or rights to use any public folders or other resources that your solution uses.

Mail forms: If your solution sends forms from one user's computer to another, did you select the Send form definition with item check box on the form's Properties page when in design mode? If not, you or the users must properly install the form so that it is available for users. Also, make sure that the computers are all using the same mode of Microsoft Outlook (Corporate Workgroup or Internet Mail Only). Sometimes the type of message format (Microsoft Rich Text, HTML, plain text, Microsoft Word) can play a role. When the message is received, is the type of message format the same as when it was sent? Is it possible the format was converted during the send process?


New items aren't using my custom form

You need to set the default form for the folder to your custom form.


Old items aren't using my custom form

You need to change the Message Class field of all the older items in the folder.


 Received mail or post form doesn't appear customized when read

Received mail or post form doesn't appear customized when read

Mail and post forms can be viewed in either Compose or Read mode. You can disable this capability so that there is only one mode for the form, or you can modify the Read and Compose pages separately. These options are on the Form menu when in design mode.


The Click event of a control doesn't fire

The Click event doesn’t fire for controls bound to a field. Because the controls are bound to a field, when the value of the field changes you can use the PropertyChange or CustomPropertyChange event.


The form is always saved with the item

If VBScript in a form changes the form itself, Microsoft Outlook may save the form definition with the item, creating a one-off item.


The macro virus warning keeps appearing

There is VBScript code in the item. To prevent this message from appearing, the VBScript code should be located in a published form. Published forms are considered safe, and therefore the macro virus warning is not displayed if the code exists in the published form.

If you published the form but still receive the warning message, this usually means one of two things: the Send form definition with item check box is selected on the form's Properties page; or the item has become a one-off form and the form definition, including VBScript code, has become part of the item itself. For more information on one-off forms, see Save a Form with the Item (One-off Forms).


 About the Message field

About the Message field

With the Message field, you can:

  • Insert file attachments or shortcuts. For example, for a Copier Request form, the Message field enables the user to attach files for copying. If the files are too large to send through the Microsoft Exchange system, the user can insert shortcuts to the attached files. In addition, the designer can insert files or shortcuts at design time. For example, you may want to insert attachments to Readme files that explain how to use the form or application.

  • Insert item attachments or shortcuts. By doing so, you can insert messages from other users in the Message field.

  • Insert a shortcut to a World Wide Web page. Recipients must have an Internet browser installed on their computers to insert shortcuts to Web pages.

  • Insert linked or embedded objects. These objects can be voice mails, Word documents, Microsoft Excel workbooks, and PowerPoint presentations.

Rules for using the Message field:

  • Each form can contain one Message control per page. For example, in a form, the Compose page can contain a Message control, and the Read page can contain a Message control.

  • You cannot have a Message control on the Message page and another page (for example, any of the pages with the label P.2 – P.6) of the Compose page or Read page.

  • If the form does not have the Separate Read Layout option selected for the page that contains the Message control, the form can only contain one Message control.

  • The Message control is automatically bound to the Message field.

  • The Message control is the only standard control on a form in which you or the user can insert files, items, or objects.


Operator summary

Operators can be used to combine and extend the functions included with Outlook.

Arithmetic operators

Comparison operators

Concatenation operators

Logical operators


 Test and publish your forms

Test and publish your forms

When your form is ready, you should test the form to make sure it works. You can test the form in run mode, then publish the form to a folder or your Personal Forms Library, and open it to see how it works. Send the form to yourself to check the Reply actions, and then publish the form to a public folder, or to your Organization Forms Library for others to use. You can also save a form to use in e-mail or as a template.

What do you want to do?

Test a form in run mode

Publish a form


 Add items to a list at design time

Add items to a list at design time

  1. In design mode, drag the ListBox or ComboBox control from the Control Toolbox to the form.

  2. Right-click the control, and then click Properties on the shortcut menu.

  3. On the Value page, click Choose Field, point to the User-defined field set, and then click the custom field to which you want the control bound.

  4. In the Possible values box, type the values for the items, separated by semicolons, that you want to appear in the list.


 Step 3: Create and use a custom view in a public folder

Step 3: Create and use a custom view in a public folder

With custom views, you can arrange information in a public folder, exactly how you want it. You can set which view is initially shown when a user opens the public folder, and you can remove all the standard views from a public folder and only show the custom views you create. By setting the permission for a public folder, you can determine who has access to the folder.

What do you want to do?

Change the default view in a folder

Show only the custom views in a folder

Restrict who uses the public folder


 Sample of instant workgroup solution

Sample of instant workgroup solution

In this example, a customer list is put in a public folder that is shared by sales managers. The view is customized so that the contacts are grouped by categories for easy scanning and sorted by business phone so the phone numbers with the same area codes appear together. Sales managers can easily add new contacts or select existing contacts who they want to call.


 Sample of a custom form based on an existing item

Sample of a custom form based on an existing item

In the sample below, the designer of the form has created a new page on a mail message named Contact and created some Outlook fields to gather information. The First, Last, and Phone fields are custom fields created by clicking New in the Field Chooser. The form is pre-addressed to a particular folder so that contacts can automatically be added to a list and then sorted, categorized, and filtered. The Created field at the bottom automatically adds the date and time the contact is sent. The Message page is hidden in run mode so the user cannot address the form to someone else. As the sales staff uses the form to record contacts, they are sent to a folder that has a view applied that groups the contacts by category and then sorts them by the Created field. In this way, a sales manager has instant access to up-to-the-minute contact information.


 Create an instant workgroup solution using public folders

Create an instant workgroup solution using public folders

By using custom views in a public folder, you can take an existing item, such as a contact, and turn it into a workgroup form from which any user of the public folder can get information or to which they can add data. With this method, you create an appointment, task, or contact in a public folder, create a custom view for the information in the folder, and then give permission to those who you want to use the folder.

To see a sample of a workgroup form in a folder, click [image] .

Click a step below to begin:

Step 1: Create a public folder

Step 2: Create an Outlook item in a public folder

Step 3: Create and use a custom view in a public folder

Step 4: Give permissions to those you want to use the folder


Abs function example

The following example returns 53 for both functions.

ABS(-53)
ABS(53)


Accelerator, Caption Properties Example

This example changes the Accelerator and Caption properties of a CommandButton each time the user clicks the button by using the mouse or the accelerator key. The Click event contains the code to change the Accelerator and Caption properties.

To try this example, paste the code into the Script Editor of a form containing a CommandButton named CommandButton1. To run the code you need to open the form so the Open event will activate.

Dim CommandButton1

Sub Item_Open()
  Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").CommandButton1
  CommandButton1.Accelerator  = "C"         'Set Accelerator key to ALT + C
End Sub

Sub CommandButton1_Click ()
  If CommandButton1.Caption = "OK" Then     'Check caption, then change it.
    CommandButton1.Caption = "Clicked"
    CommandButton1.Accelerator  = "C"         'Set Accelerator key to ALT + C
  Else
    CommandButton1.Caption = "OK"
    CommandButton1.Accelerator  = "O"         'Set Accelerator key to ALT + O
  End If
End Sub


Accessing Controls Through the Controls Collection Example

The following example accesses individual controls from the Controls collection using a For Each...Next loop. When the user presses CommandButton1, the other controls are placed in a column along the left edge of the form using the Move method.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains a CommandButton named CommandButton1 and several other controls.

Dim CtrlHeight
Dim CtrlTop
Dim CtrlGap
Dim CommandButton1

Sub Item_Open()
  Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").CommandButton1

  CtrlHeight = 20
  CtrlGap = 5

  CommandButton1.Caption = "Click to move controls"
  CommandButton1.AutoSize = True
  CommandButton1.Left = 120
  CommandButton1.Top = CtrlTop
End Sub

Sub CommandButton1_Click()
  Dim MyControl

  Set AllControls = Item.GetInspector.ModifiedFormPages("P.2").Controls

  CtrlTop = 5

  For i = 0 to AllControls.Count - 1
    Set MyControl = AllControls(i)
    If MyControl.Name = "CommandButton1" Then
    'Don't move or resize this control.
    Else
      'Move method using unnamed arguments (left, top, width, height)
      MyControl.Move 5, CtrlTop, ,CtrlHeight

      'Calculate top coordinate for next control
      CtrlTop = CtrlTop + CtrlHeight + CtrlGap
    End If
  Next

End Sub


Accessing a Page Example

The following example accesses an individual page of a MultiPage in several ways:

  • Using the Pages collection with a numeric index.

  • Using the name of the individual page in the MultiPage.

  • Using the SelectedItem property.

To use this example, copy this sample code to the Script Editor of a form. Make sure that the form contains a MultiPage named MultiPage1 and a CommandButton named CommandButton1.

Sub CommandButton1_Click
  Dim PageName
  Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").MultiPage1

  For i = 0 To MultiPage1.Count - 1
    'Use index (numeric or string)
    MsgBox "MultiPage1.Pages(i).Caption = " & MultiPage1.Pages(i).Caption
    MsgBox "MultiPage1.Pages.Item(i).Caption = " & MultiPage1.Pages.Item(i).Caption

    'Use Page object without referring to Pages collection
    If i = 0 Then
      MsgBox "MultiPage1.Page1.Caption = " & MultiPage1.Page1.Caption
    ElseIf i = 1 Then
      MsgBox "MultiPage1.Page2.Caption = " & MultiPage1.Page2.Caption
    End If

    'Use SelectedItem Property
    MultiPage1.Value = i
    MsgBox "MultiPage1.SelectedItem.Caption = " & MultiPage1.SelectedItem.Caption
  Next
End Sub


Accessing a Tab Example

The following example accesses an individual tab of a TabStrip in several ways:

  • Using the Tabs collection with a numeric index.

  • Using the name of the individual Tab.

  • Using the SelectedItem property.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains a TabStrip named TabStrip1.

Sub Item_Open()
    Dim TabStrip1
    Dim TabName

     Set TabStrip1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("TabStrip1")
    For i = 0 To TabStrip1.Count - 1
        'Using index (numeric or string)
        MsgBox "TabStrip1.Tabs(i).Caption = " & TabStrip1.Tabs(i).Caption
        MsgBox "TabStrip1.Tabs.Item(i).Caption = " & TabStrip1.Tabs.Item(i).Caption

        'Use Tab object without referring to Tabs collection
        If i = 0 Then
            MsgBox "TabStrip1.Tab1. Caption = " & TabStrip1.Tab1.Caption
        ElseIf i = 1 Then
            MsgBox "TabStrip1.Tab2. Caption = " & TabStrip1.Tab2.Caption
        End If

        'Use SelectedItem Property
        TabStrip1.Value = i
        MsgBox " TabStrip1.SelectedItem.Caption = " & TabStrip1.SelectedItem.Caption
    Next
End Sub


 Adding a Control Example

Adding a Control Example

The following example uses the Add method to add a control to a form at run time.

To use this example, copy this sample code to the Script Editor of a form. Make sure that the form contains:

  • A CommandButton named CommandButton1.
Dim Mycmd
Sub CommandButton1_Click()

   Set Mycmd = Item.GetInspector.ModifiedFormPages("P.2").Controls.Add("Forms.CommandButton.1") ', CommandButton2, Visible)
  Mycmd.Left = 18
  Mycmd.Top = 150
  Mycmd.Width = 175
  Mycmd.Height = 20
  Mycmd.Caption = "This is fun." & Mycmd.Name

End Sub


Adding a Control to a MultiPage Example

The following example uses the Add, Clear, and Remove methods to add and remove a control to a Page of a MultiPage at run time.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A MultiPage named MultiPage1.

  • Three CommandButton controls named CommandButton1 through CommandButton3.
Dim MyTextBox
Dim MultiPage1

Sub Item_Open()
  Set MyPage = Item.GetInspector.ModifiedFormPages("P.2")
  Set MultiPage1 = MyPage.MultiPage1
  MyPage.CommandButton1.Caption = "Add control"
  MyPage.CommandButton2.Caption = "Clear controls"
  MyPage.CommandButton3.Caption = "Remove control"
End Sub

Sub CommandButton1_Click()
  Set MyTextBox = MultiPage1.Pages(0).Controls.Add("Forms.TextBox.1", "MyTextBox", 1)
End Sub

Sub CommandButton2_Click()
  MultiPage1.Pages(0).Controls.Clear
End Sub

Sub CommandButton3_Click()
  If MultiPage1.Pages(0).Controls.Count > 0  Then
    MultiPage1.Pages(0).Controls.Remove "MyTextBox"
  End If
End Sub


Alignment Property Example

The following example demonstrates the Alignment property used with several OptionButton controls. In this example, the user can change the alignment by clicking a ToggleButton.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains the following controls:

  • Two OptionButton controls named OptionButton1 and OptionButton2.

  • A ToggleButton named ToggleButton1.
Dim OptionButton1
Dim OptionButton2
Dim ToggleButton1

Sub Item_Open()
     Set OptionButton1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("OptionButton1")
     Set OptionButton2 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("OptionButton2")
     Set ToggleButton1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("ToggleButton1")

    OptionButton1.Alignment = 0 'fmAlignmentLeft
    OptionButton2.Alignment = 0 'fmAlignmentLeft

    OptionButton1.Caption = "Alignment with AutoSize"
    OptionButton2.Caption = "Choice 2"
    OptionButton1.AutoSize = True
    OptionButton2.AutoSize = True

    ToggleButton1.Caption = "Left Align"
    ToggleButton1.WordWrap = True
    ToggleButton1.Value = True
End Sub

Sub ToggleButton1_Click()
    If ToggleButton1.Value = True Then
        ToggleButton1.Caption = "Left Align"
        OptionButton1.Alignment = 0 'fmAlignmentLeft
        OptionButton2.Alignment = 0 'fmAlignmentLeft
    Else
        ToggleButton1.Caption = "Right Align"
        OptionButton1.Alignment = 1 'fmAlignmentRight
        OptionButton2.Alignment = 1 'fmAlignmentRight
    End If
End Sub


Asc function example

The following example returns the character code of the first letter in the Subject field.

Subject field | Function returns
International Sales | 73
Marketing Strategy | 77

ASC([Subject])


Atn function example

The following example uses the Atn function to return the value of pi.

ATN(1)*4


AutoSize Property Example

The following example demonstrates the effects of the AutoSize property with a single-line TextBox and a multiline TextBox. The user can enter text into either of the TextBox controls and turn AutoSize on or off independently of the contents of the TextBox. This code sample also uses the Text property.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • Two TextBox controls named TextBox1 and TextBox2.

  • A ToggleButton named ToggleButton1.
Dim ToggleButton1
Dim TextBox1
Dim TextBox2

Sub Item_Open()
  Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").ToggleButton1
  Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").TextBox1
  Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").TextBox2

  TextBox1.Text = "Single-line TextBox. Type your text here."

  TextBox2.MultiLine = True
  TextBox2.Text = "Multi-line TextBox. Type your text here. Use SHIFT+ENTER to start a new line."

  ToggleButton1.Value = True
  ToggleButton1.Caption = "AutoSize On"
  TextBox1.AutoSize = True
  TextBox2.AutoSize = True
End Sub

Sub ToggleButton1_Click()
  If ToggleButton1.Value = True Then
    ToggleButton1.Caption = "AutoSize On"
    TextBox1.AutoSize = True
    TextBox2.AutoSize = True
  Else
    ToggleButton1.Caption = "AutoSize Off"
    TextBox1.AutoSize = False
    TextBox2.AutoSize = False
  End If
End Sub


Bold, Italic, Size, StrikeThrough, Underline, Weight Properties Example

The following example demonstrates a Font object and the Bold, Italic, Size, StrikeThrough, Underline, and Weight properties related to fonts. You can manipulate font properties of an object directly or by using an alias, as this example also shows.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A Label named Label1.

  • Four ToggleButton controls named ToggleButton1 through ToggleButton4.

  • A second Label and a TextBox named Label2 and TextBox1.
Dim MyFont
Dim ToggleButton1
Dim ToggleButton2
Dim ToggleButton3
Dim ToggleButton4
Dim Label1
Dim Label2
Dim TextBox1

Sub Item_Open()
  Set MyPage = Item.GetInspector.ModifiedFormPages("P.2")
  Set ToggleButton1 = MyPage.ToggleButton1
  Set ToggleButton2 = MyPage.ToggleButton2
  Set ToggleButton3 = MyPage.ToggleButton3
  Set ToggleButton4 = MyPage.ToggleButton4
  Set Label1 = MyPage.Label1
  Set Label2 = MyPage.Label2
  Set TextBox1 = MyPage.TextBox1
  Set MyFont = Label1.Font

  ToggleButton1.Value = True
  ToggleButton1.Caption = "Bold On"

  Label1.AutoSize = True        'Set size of Label1
  Label1.AutoSize = False

  ToggleButton2.Value = False
  ToggleButton2.Caption = "Italic Off"

  ToggleButton3.Value = False
  ToggleButton3.Caption = "StrikeThrough Off"

  ToggleButton4.Value = False
  ToggleButton4.Caption = "Underline Off"

  Label2.Caption = "Font Weight"
  TextBox1.Text = Label1.Font.Weight
  TextBox1.Enabled = False

End Sub

Sub ToggleButton1_Click()
  If ToggleButton1.Value = True Then
    MyFont.Bold = True            'Using MyFont alias to control font
    ToggleButton1.Caption = "Bold On"
    MyFont.Size = 22              'Increase the font size
  Else
    MyFont.Bold = False
    ToggleButton1.Caption = "Bold Off"
    MyFont.Size = 8               'Return font size to initial size
  End If

  TextBox1.Text = CStr(MyFont.Weight)  'Bold and Weight are related
End Sub

Sub ToggleButton2_Click()
  If ToggleButton2.Value = True Then
    Label1.Font.Italic = True            'Using Label1.Font directly
    ToggleButton2.Caption = "Italic On"
  Else
    Label1.Font.Italic = False
    ToggleButton2.Caption = "Italic Off"
  End If
End Sub

Sub ToggleButton3_Click()
  If ToggleButton3.Value = True Then
    Label1.Font.Strikethrough = True            'Using Label1.Font directly
    ToggleButton3.Caption = "StrikeThrough On"
  Else
    Label1.Font.Strikethrough = False
    ToggleButton3.Caption = "StrikeThrough Off"
  End If
End Sub

Sub ToggleButton4_Click()
  If ToggleButton4.Value = True Then
    MyFont.Underline = True            'Using MyFont alias for Label1.Font
    ToggleButton4.Caption = "Underline On"
  Else
    Label1.Font.Underline = False
    ToggleButton4.Caption = "Underline Off"
  End If
End Sub


Border, Color Enhancements Example

The following example demonstrates the BorderStyle and SpecialEffect properties, showing each border available through these properties. The example also demonstrates how to control color settings by using the BackColor, BackStyle, BorderColor, and ForeColor properties.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • Six TextBox controls named TextBox1 through TextBox6.

  • Two ToggleButton controls named ToggleButton1 and ToggleButton2.
Dim TextBox1
Dim TextBox2
Dim TextBox3
Dim TextBox4
Dim TextBox5
Dim TextBox6
Dim ToggleButton1
Dim ToggleButton2

Sub Item_Open()
Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").TextBox1
Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").TextBox2
Set TextBox3 = Item.GetInspector.ModifiedFormPages("P.2").TextBox3
Set TextBox4 = Item.GetInspector.ModifiedFormPages("P.2").TextBox4
Set TextBox5 = Item.GetInspector.ModifiedFormPages("P.2").TextBox5
Set TextBox6 = Item.GetInspector.ModifiedFormPages("P.2").TextBox6
Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").ToggleButton1
Set ToggleButton2 = Item.GetInspector.ModifiedFormPages("P.2").ToggleButton2

'Initialize each TextBox with a border style or special effect,
'and foreground and background colors

'TextBox1 initially uses a borderstyle
TextBox1.Text = "BorderStyle-Single"
TextBox1.BorderStyle = 1
TextBox1.BorderColor = RGB(255, 128, 128)   'Color - Salmon
TextBox1.ForeColor = RGB(255, 255, 0)       'Color - Yellow
TextBox1.BackColor = RGB(0, 128, 64)        'Color - Green #2

'TextBoxes 2 through 6 initially use special effects
TextBox2.Text = "Flat"
TextBox2.SpecialEffect = 0
TextBox2.ForeColor = RGB(64, 0, 0)          'Color - Brown
TextBox2.BackColor = RGB(0, 0, 255)         'Color - Blue

'Ensure the background style for TextBox2 is initially opaque.
TextBox2.BackStyle = 1

TextBox3.Text = "Etched"
TextBox3.SpecialEffect = 3
TextBox3.ForeColor = RGB(128, 0, 255)       'Color - Purple
TextBox3.BackColor = RGB(0, 255, 255)       'Color - Cyan

'Define BorderColor for later use (when borderstyle=fmBorderStyleSingle)
TextBox3.BorderColor = RGB(0, 0, 0)         'Color - Black

TextBox4.Text = "Bump"
TextBox4.SpecialEffect = 6
TextBox4.ForeColor = RGB(255, 0, 255)       'Color - Magenta
TextBox4.BackColor = RGB(0, 0, 100)         'Color - Navy blue

TextBox5.Text = "Raised"
TextBox5.SpecialEffect = 1
TextBox5.ForeColor = RGB(255, 0, 0)         'Color - Red
TextBox5.BackColor = RGB(128, 128, 128)     'Color - Gray

TextBox6.Text = "Sunken"
TextBox6.SpecialEffect = 2
TextBox6.ForeColor = RGB(0, 64, 0)          'Color - Olive
TextBox6.BackColor = RGB(0, 255, 0)         'Color - Green #1

ToggleButton1.Caption = "Swap styles"
ToggleButton2.Caption = "Transparent/Opaque background"
End Sub

Sub ToggleButton1_Click()

'Swap borders between TextBox1 and TextBox3
If ToggleButton1.Value = True Then
    'Change TextBox1 from BorderStyle to Etched
    TextBox1.Text = "Etched"
    TextBox1.SpecialEffect = 3

    'Change TextBox3 from Etched to BorderStyle
    TextBox3.Text = "BorderStyle-Single"
    TextBox3.BorderStyle = 1
Else
    'Change TextBox1 back to BorderStyle
    TextBox1.Text = "BorderStyle-Single"
    TextBox1.BorderStyle = 1

    'Change TextBox3 back to Etched
    TextBox3.Text = "Etched"
    TextBox3.SpecialEffect = 3
End If
End Sub

Sub ToggleButton2_Click()

'Set background to Opaque or Transparent
If ToggleButton2.Value = True Then
    'Change TextBox2 to a transparent background
    TextBox2.BackStyle = 0
Else
    'Change TextBox2 back to opaque background
    TextBox2.BackStyle = 1
End If

End Sub


BoundColumn Property Example

The following example demonstrates how the BoundColumn property influences the value of a ListBox. The user can choose to set the value of the ListBox to the index value of the specified row, or to a specified column of data in the ListBox.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A ListBox named ListBox1.

  • A Label named Label1.

  • Three OptionButton controls named OptionButton1, OptionButton2, and OptionButton3.
Dim Listbox1
Dim OptionButton1
Dim OptionButton2
Dim OptionButton3
Dim Label1

Sub Item_Open
  Set Listbox1 = Item.GetInspector.ModifiedFormPages("P.2").Listbox1
  Set OptionButton1 = Item.GetInspector.ModifiedFormPages("P.2").OptionButton1
  Set OptionButton2 = Item.GetInspector.ModifiedFormPages("P.2").OptionButton2
  Set OptionButton3 = Item.GetInspector.ModifiedFormPages("P.2").OptionButton3
  Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Label1

  Listbox1.ColumnCount = 2
  Listbox1.AddItem "Item 1, Column 1"
  Listbox1.List(0, 1) = "Item 1, Column 2"
  Listbox1.AddItem "Item 2, Column 1"
  Listbox1.List(1, 1) = "Item 2, Column 2"
  Listbox1.Value  = "Item 1, Column 1"
  OptionButton1.Caption = "List Index"
  OptionButton2.Caption = "Column 1"
  OptionButton3.Caption = "Column 2"
  OptionButton2.Value = True
End Sub

Sub OptionButton1_Click
  Listbox1.BoundColumn = 0
  Label1.Caption = Listbox1.Value
End Sub

Sub OptionButton2_Click
  Listbox1.BoundColumn = 1
  Label1.Caption = Listbox1.Value
End Sub

Sub OptionButton3_Click
  Listbox1.BoundColumn = 2
  Label1.Caption = Listbox1.Value
End Sub

Sub Listbox1_Click
  Label1.Caption = Listbox1.Value
End Sub


UndoAction, RedoAction Methods Example

The following example demonstrates how to undo or redo text editing within a text box or within the text area of a ComboBox. This sample checks whether an undo or redo operation can occur and then performs the appropriate action. The sample uses the CanUndo and CanRedo properties, and the UndoAction and RedoAction methods.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A TextBox named TextBox1.

  • A ComboBox named ComboBox1.

  • Two CommandButton controls named CommandButton1 and CommandButton2.
Dim UserForm1

Sub CommandButton1_Click()
    If UserForm1.CanUndo = True Then
        UserForm1.UndoAction
        MsgBox "Undid IT"
    Else
        MsgBox "No undo performed."
    End If
End Sub

Sub CommandButton2_Click()
    If UserForm1.CanRedo = True Then
        UserForm1.RedoAction
        MsgBox "Redid IT"
    Else
        MsgBox "No redo performed."
    End If
End Sub

Sub Item_Open()
     Set UserForm1 = Item.GetInspector.ModifiedFormPages("P.2")
     Set TextBox1 = UserForm1.Controls("TextBox1")
     Set ComboBox1 = UserForm1.Controls("ComboBox1")
     Set CommandButton1 = UserForm1.Controls("CommandButton1")
     Set CommandButton2 = UserForm1.Controls("CommandButton2")

    TextBox1.Text = "Type your text here."

    ComboBox1.ColumnCount = 3
    ComboBox1.AddItem "Choice 1, column 1"
    ComboBox1.List(0, 1) = "Choice 1, column 2"
    ComboBox1.List(0, 2) = "Choice 1, column 3"

    CommandButton1.Caption = "Undo"
    CommandButton2.Caption = "Redo"
End Sub


Choose function example

The following examples use the Choose function to display custom values for the value of the Importance field.

Importance field | Function returns
0 | Ignore
1 | Read Today
2 | Read Yesterday

Choose([Importance]+1, "Ignore", "Read Today", "Read Yesterday")


Chr function example

The example returns the character for the following character codes in the CharCode field.

CharCode field | Function returns
65 | A
97 | a
62 | >
37 | %

Chr([CharCode])


ClientHeight, ClientLeft, ClientTop, ClientWidth Properties Example

The following example sets the dimensions of an Image to the size of a TabStrip's client area when the user clicks a CommandButton. This code sample uses the following properties: Height, Left, Top, Width, ClientHeight, ClientLeft, ClientTop, and ClientWidth.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A CommandButton named CommandButton1.

  • A TabStrip named TabStrip1.

  • An Image named Image1.
Dim CommandButton1
Dim Image1
Dim TabStrip1

Sub Item_Open
  Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").CommandButton1
  Set Image1 = Item.GetInspector.ModifiedFormPages("P.2").Image1
  Set TabStrip1 = Item.GetInspector.ModifiedFormPages("P.2").TabStrip1

  CommandButton1.Caption = "Size Image to Tab Area"
  CommandButton1.WordWrap = True
  CommandButton1.AutoSize = True
End Sub

Sub CommandButton1_Click
  Image1.ZOrder (fmFront) 'Place Image in front of TabStrip

'Client Left and ClientTop are measured from the edge of the TabStrip,
'not from the edges of the form containing the TabStrip.
  Image1.Left = TabStrip1.Left + TabStrip1.ClientTop
  Image1.Top = TabStrip1.Top + TabStrip1.ClientTop
  Image1.Width = TabStrip1.ClientWidth
  Image1.Height = TabStrip1.ClientHeight
End Sub


Column Property Example

'

The following example loads a two-dimensional array with data and, in turn, loads two ListBox controls using the Column and List properties. Note that the Column property transposes the array elements during loading.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains two ListBox controls named ListBox1 and ListBox2.

Dim MyArray(6,3)

Sub Item_Open()
    Dim i

    Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").ListBox1
    Set ListBox2 = Item.GetInspector.ModifiedFormPages("P.2").ListBox2

    ListBox1.ColumnCount = 3        'The 1st list box contains 3 data columns
    ListBox2.ColumnCount = 6        'The 2nd box contains 6 data columns

    'Load integer values into first column of MyArray
    For i = 0 To 5
        MyArray(i, 0) = i
    Next

    'Load columns 2 and three of MyArray
    MyArray(0, 1) = "Zero"
    MyArray(1, 1) = "One"
    MyArray(2, 1) = "Two"
    MyArray(3, 1) = "Three"
    MyArray(4, 1) = "Four"
    MyArray(5, 1) = "Five"

    MyArray(0, 2) = "Zero"
    MyArray(1, 2) = "Un ou Une"
    MyArray(2, 2) = "Deux"
    MyArray(3, 2) = "Trois"
    MyArray(4, 2) = "Quatre"
    MyArray(5, 2) = "Cinq"

    'Load data into ListBox1 and ListBox2
    ListBox1.List() = MyArray
    ListBox2.Column() = MyArray

End Sub


ColumnWidths Property Example

The following example uses the ColumnWidths property to change the column widths of a multicolumn ListBox. The example uses three TextBox controls to specify the individual column widths and uses the Exit event to specify the units of measure of each TextBox.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A ListBox named ListBox1.

  • Three custom text fields named Text1, Text2, and Text3.

  • Three TextBox controls named TextBox1, TextBox2, and TextBox3 that are bound to the custom text fields above.

  • A CommandButton named CommandButton1.

Try entering the value 0 to hide a column.

Dim MyArray(2, 3)
Dim ListBox1
Dim TextBox1
Dim TextBox2
Dim TextBox3
Dim CommandButton1

Sub Item_Open()
Dim i, j, Rows

Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").ListBox1
Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").TextBox1
Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").TextBox2
Set TextBox3 = Item.GetInspector.ModifiedFormPages("P.2").TextBox3
Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").CommandButton1

ListBox1.ColumnCount = 3
Rows = 2

For j = 0 To ListBox1.ColumnCount - 1
    For i = 0 To Rows - 1
        MyArray(i, j) = "Row " & i & ", Column " & j
    Next
Next

ListBox1.List() = MyArray           'Load MyArray into ListBox1

TextBox1.Text = "1 in"              '1-inch columns initially
TextBox2.Text = "1 in"
TextBox3.Text = "1 in"

End Sub

Sub CommandButton1_Click()
    'ColumnWidths requires a value for each column separated by semicolons
    ListBox1.ColumnWidths = TextBox1.Text & ";" & TextBox2.Text & ";" & TextBox3.Text
End Sub

Sub Item_CustomPropertyChange(ByVal Name)
msgbox Name
Select Case Name
Case "Text1"
  'ColumnWidths accepts points (no units), inches or centimeters; make inches the default
    If Not (InStr(TextBox1.Text, "in") > 0 Or InStr(TextBox1.Text, "cm") > 0) Then
        TextBox1.Text = TextBox1.Text & " in"
    End If
Case "Text2"
    'ColumnWidths accepts points (no units), inches or centimeters; make inches the default
    If Not (InStr(TextBox2.Text, "in") > 0 Or InStr(TextBox2.Text, "cm") > 0) Then
        TextBox2.Text = TextBox2.Text & " in"
    End If
Case "Text3"
    'ColumnWidths accepts points (no units), inches or centimeters; make inches the default
    If Not (InStr(TextBox3.Text, "in") > 0 Or InStr(TextBox3.Text, "cm") > 0) Then
        TextBox3.Text = TextBox3.Text & " in"
    End If
End Select
End Sub


ControlTipText Property Example

The following example defines the ControlTipText property for three CommandButton controls and two Page objects in a MultiPage.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A MultiPage named MultiPage1.

  • Three CommandButton controls named CommandButton1 through CommandButton3.

Note For an individual Page of a MultiPage, ControlTipText becomes enabled when the MultiPage or a control on the current page of the MultiPage has the focus.

Sub Item_Open()
  Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").MultiPage1
  Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").CommandButton1
  Set CommandButton2 = Item.GetInspector.ModifiedFormPages("P.2").CommandButton2
  Set CommandButton3 = Item.GetInspector.ModifiedFormPages("P.2").CommandButton3

  MultiPage1.Page1.ControlTipText = "Here in page 1"
  MultiPage1.Page2.ControlTipText = "Now in page 2"

  CommandButton1.ControlTipText = "And now here's"
  CommandButton2.ControlTipText = "a tip from"
  CommandButton3.ControlTipText = "your controls!"
End Sub


Cos function example

The following example uses the Cos function to return the cosine of the Angle field.

Cos([Angle])


 Count Property Example

Count Property Example

The following example displays the Count property of the Controls collection for the form, and the Count property identifying the number of pages and tabs of each MultiPage and TabStrip.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. The form can contain any number of controls, with the following restrictions:

  • Names of MultiPage controls must start with "MultiPage".

  • Names of TabStrip controls must start with "TabStrip".

Note You can add pages to a MultiPage or add tabs to a TabStrip while in design mode. Double-click on the control, then right click in the tab area of the control and choose New Page from the shortcut menu.

Sub Item_Open
    Dim Controls
    Dim MyControl

    Set Controls = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls
    MsgBox "Controls.Count = " & Controls.Count
    For i = 0 to Controls.Count -1
        Set MyControl = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls.Item(i)
        If (MyControl.Name = "MultiPage1") Then
            MsgBox MyControl.Name & ".Pages.Count = " & MyControl.Pages.Count
        ElseIf (MyControl.Name = "TabStrip1") Then
            MsgBox MyControl.Name & ".Tabs.Count = " & MyControl.Tabs.Count
        End If
    Next
End Sub


Cut and Paste From a Page Example

The following example uses the Add, Cut, and Paste methods to cut and paste a control from a Page of a MultiPage. The control involved in the cut and paste operations is dynamically added to the form.

This example assumes the user will add, then cut, then paste the new control.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • Three CommandButton controls named CommandButton1 through CommandButton3.

  • A MultiPage named MultiPage1.
Dim CommandButton1
Dim CommandButton2
Dim CommandButton3
Dim MultiPage1
Dim MyTextBox

Sub CommandButton1_Click()
    Set MyTextBox = MultiPage1.Pages(MultiPage1.Value).Controls.Add("Forms.TextBox.1", "MyTextBox", 1)
    CommandButton2.Enabled = True
    CommandButton1.Enabled = False
End Sub

Sub CommandButton2_Click()
    MultiPage1.Pages(MultiPage1.Value).Controls.Cut
    CommandButton3.Enabled = True
    CommandButton2.Enabled = False
End Sub

Sub CommandButton3_Click()
    Dim MyPage
    Set MyPage = MultiPage1.Pages.Item(MultiPage1.Value)

    MyPage.Paste
    CommandButton3.Enabled = False
End Sub

Sub Item_Open()
    Set CommandButton1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("CommandButton1")
    Set CommandButton2 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("CommandButton2")
    Set CommandButton3 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("CommandButton3")
    Set MultiPage1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("MultiPage1")

    CommandButton1.Caption = "Add"
    CommandButton2.Caption = "Cut"
    CommandButton3.Caption = "Paste"

    CommandButton1.Enabled = True
    CommandButton2.Enabled = False
    CommandButton3.Enabled = False
End Sub


Cut and Paste From a TextBox Example

The following example uses the Cut and Paste methods to cut text from one TextBox and paste it into another TextBox.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • Two TextBox controls named TextBox1 and TextBox2.

  • A CommandButton named CommandButton1.
Dim TextBox1
Dim TextBox2
Dim CommandButton1

Sub Item_Open()
    Set TextBox1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("TextBox1")
    Set TextBox2 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("TextBox2")
    Set CommandButton1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("CommandButton1")

    TextBox1.Text = "From TextBox1!"
    TextBox2.Text = "Hello "

    CommandButton1.Caption = "Cut and Paste"
    CommandButton1.AutoSize = True
End Sub

Sub CommandButton1_Click()
    TextBox2.SelStart = 0
    TextBox2.SelLength = TextBox2.TextLength
    TextBox2.Cut

    TextBox1.SetFocus
    TextBox1.SelStart = 0

    TextBox1.Paste
    TextBox2.SelStart = 0
End Sub


Cycle Property Example

The following example defines the Cycle property for a Frame and two Page objects in a MultiPage.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A Frame named Frame1.

  • A MultiPage named MultiPage1 that contains two objects named Page1 and Page2.

  • Two CommandButton controls named CommandButton1 and CommandButton2.

In the form, the Frame, and each Page of the MultiPage, place a couple of controls, so you can see how Cycle affects the tab order of the Frame and MultiPage.

The user should tab through the controls to observe how Cycle affects the tab order. Pressing CommandButton1 extends the tab order to include controls in the Frame and Page objects. Pressing CommandButton2 restricts the tab order.

Dim Frame1
Dim MultiPage1

Sub Item_Open()
  Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Frame1
  Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").MultiPage1
  RestrictCycles
End Sub

Sub RestrictCycles()
  'Limit tab order for the Frame and Page objects
  Frame1.Cycle = 2
  MultiPage1.Page1.Cycle = 2
  MultiPage1.Page2.Cycle = 2
End Sub

Sub CommandButton1_Click()
  'Extend tab order subforms (the Frame and Page objects)
  Frame1.Cycle = 0
  MultiPage1.Page1.Cycle = 0
  MultiPage1.Page2.Cycle = 0
End Sub

Sub CommandButton2_Click()
  RestrictCycles
End Sub


DateAdd function example

The following example takes the date of the Received field and, by using the DateAdd function, displays a corresponding date one month in the future.

DateAdd("m", 1, [Received])


DateDiff function example

The following example uses the DateDiff function to display the number of days between the date in the Received field and the current system date.

DateDiff("d", Now(), [Received])


Date function example

The following example uses the Date function to return the current system date.

Date( )


DatePart function example

The following example takes the date Received field and, by using the DatePart function, displays the quarter of the year it falls in.

DatePart("q", [Received])


DateSerial function example

The following example uses the DateSerial function to return the date for the specified year, month, and day.

DateSerial(1969, 2, 12)


DateValue function example

The following example uses the DateValue function to convert a string to a date.

DateValue("February 12, 1969")


Day function example

The following example uses the Day function to return the day of the Received field.

Day([Received])


DDB function example

By using the double-declining balance method, this example uses the DDB function to return the depreciation of an asset for a specified period given the initial cost (InitCost), the salvage value at the end of the asset's useful life (SalvageVal), the total life of the asset in years (LifeTime), and the period for which the depreciation is calculated (Depr), also in years.

DDB([InitCost], [SalvageVal], [LifeTime], [Depr])


DragBehavior, EnterFieldBehavior Properties Example

The following example uses the DragBehavior and EnterFieldBehavior properties to demonstrate the different effects that you can provide when entering a control and when dragging information from one control to another.

The sample uses two TextBox controls. You can set DragBehavior and EnterFieldBehavior for each control and see the effects of dragging from one control to another.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A TextBox named TextBox1.

  • Two ToggleButton controls named ToggleButton1 and ToggleButton2. These controls are associated with TextBox1.

  • A TextBox named TextBox2.

  • Two ToggleButton controls named ToggleButton3 and ToggleButton4. These controls are associated with TextBox2.
Dim TextBox1, TextBox2
Dim ToggleButton1, ToggleButton2, ToggleButton3, ToggleButton4

Sub Item_Open()
     set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
     set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox2")
     set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton1")
     set ToggleButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton2")
     set ToggleButton3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton3")
     set ToggleButton4 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton4")

    TextBox1.Text = "Once upon a time in a land ...,"
    ToggleButton1.Value = True
    ToggleButton1.Caption = "Drag Enabled"
    ToggleButton1.WordWrap = True
    TextBox1.DragBehavior = 1 'fmDragBehaviorEnabled

    ToggleButton2.Value = True
    ToggleButton2.Caption = "Recall Selection"
    ToggleButton2.WordWrap = True
    TextBox1.EnterFieldBehavior = 1 'fmEnterFieldBehaviorRecallSelection

    TextBox2.Text = "XXX, YYYY"
    ToggleButton3.Value = False
    ToggleButton3.Caption = "Drag Disabled"
    ToggleButton3.WordWrap = True
    TextBox2.DragBehavior = 0 'fmDragBehaviorDisabled

    ToggleButton4.Value = False
    ToggleButton4.Caption = "Select All"
    ToggleButton4.WordWrap = True
    TextBox2.EnterFieldBehavior = 0 'fmEnterFieldBehaviorSelectAll
End Sub

Sub ToggleButton1_Click()
    If ToggleButton1.Value = True Then
       ToggleButton1.Caption = "Drag Enabled"
       TextBox1.DragBehavior = 1 'fmDragBehaviorEnabled
    Else
       ToggleButton1.Caption = "Drag Disabled"
       TextBox1.DragBehavior = 0 'fmDragBehaviorDisabled
    End If
End Sub

Sub ToggleButton2_Click()
    If ToggleButton2.Value = True Then
        ToggleButton2.Caption = "Recall Selection"
        TextBox1.EnterFieldBehavior = 1 'fmEnterFieldBehaviorRecallSelection
    Else
        ToggleButton2.Caption = "Select All"
        TextBox1.EnterFieldBehavior = 0 'fmEnterFieldBehaviorSelectAll
    End If
End Sub

Sub ToggleButton3_Click()
    If ToggleButton3.Value = True Then
       ToggleButton3.Caption = "Drag Enabled"
       TextBox2.DragBehavior = 1 'fmDragBehaviorEnabled
    Else
       ToggleButton3.Caption = "Drag Disabled"
       TextBox2.DragBehavior = 0 'fmDragBehaviorDisabled
    End If
End Sub

Sub ToggleButton4_Click()
    If ToggleButton4.Value = True Then
        ToggleButton4.Caption = "Recall Selection"
        TextBox2.EnterFieldBehavior = 1 'fmEnterFieldBehaviorRecallSelection
    Else
       ToggleButton4.Caption = "Select All"
       TextBox2.EnterFieldBehavior = 0 'fmEnterFieldBehaviorSelectAll
    End If
End Sub


DropButtonStyle, ShowDropButtonWhen Properties Example

The following example demonstrates the different symbols that you can specify for a drop-down arrow in a ComboBox or TextBox. In this example, the user chooses a drop-down arrow style from a ComboBox. This example also uses the Locked property. To use this example, copy this sample code to the Script Editor of a form. Make sure that the form contains:

  • A ComboBox named ComboBox1.

  • A Label named Label1.

  • A TextBox named TextBox1 placed beneath Label1.
Dim TextBox1
Dim ComboBox1
Dim Label1

Sub ComboBox1_Click()
    ComboBox1.DropButtonStyle = ComboBox1.Value
    TextBox1.DropButtonStyle = ComboBox1.Value
End Sub

Sub Item_Open()
     Set TextBox1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("TextBox1")
     Set ComboBox1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("ComboBox1")
     Set Label1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("Label1")

    ComboBox1.ColumnCount = 2
    ComboBox1.BoundColumn = 2
    ComboBox1.TextColumn = 1

    ComboBox1.AddItem "Blank Button"
    ComboBox1.List(0, 1) = 0
    ComboBox1.AddItem "Down Arrow"
    ComboBox1.List(1, 1) = 1
    ComboBox1.AddItem "Ellipsis"
    ComboBox1.List(2, 1) = 2
    ComboBox1.AddItem "Underscore"
    ComboBox1.List(3, 1) = 3

    ComboBox1.Value = 0

    TextBox1.Text = "TextBox1"
    TextBox1.ShowDropButtonWhen = 2 'fmShowDropButtonWhenAlways
    TextBox1.Locked = True

    Label1.Caption = "TheDropButton also applies to a TextBox."
    Label1.AutoSize = True
    Label1.WordWrap = False
End Sub


DropDown Method Example

The following example uses the DropDown method to display the list in a ComboBox. The user can display the list of a ComboBox by clicking the CommandButton.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A ComboBox named ComboBox1.

  • A CommandButton named CommandButton1.
Dim ComboBox1

Sub CommandButton1_Click()
    ComboBox1.DropDown
End Sub

Sub Item_Open()
     Set ComboBox1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("ComboBox1")
    ComboBox1.AddItem "Turkey"
    ComboBox1.AddItem "Chicken"
    ComboBox1.AddItem "Duck"
    ComboBox1.AddItem "Goose"
    ComboBox1.AddItem "Grouse"
End Sub


Enabled, Locked Properties Example

The following example demonstrates the Enabled and Locked properties and how they complement each other. This example exposes each property independently with a CheckBox, so you observe the settings individually and combined. This example also includes a second TextBox so you can copy and paste information between the TextBox controls and verify the activities supported by the settings of these properties.

Note You can copy the selection to the Clipboard using CTRL+C and paste using CTRL+V.

To use this example, copy this sample code to the Script Editor of a form. Make sure that the form contains:

  • A TextBox named TextBox1.

  • Two CheckBox controls named CheckBox1 and CheckBox2.

  • A second TextBox named TextBox2.
Dim TextBox1
Dim TextBox2
Dim CheckBox1
Dim CheckBox2

Sub CheckBox1_Click()
    TextBox2.Text = "TextBox2"
    TextBox1.Enabled = CheckBox1.Value
End Sub

Sub CheckBox2_Click()
    TextBox2.Text = "TextBox2"
    TextBox1.Locked = CheckBox2.Value
End Sub

Sub Item_Open()
     Set TextBox1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("TextBox1")
     Set TextBox2 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("TextBox2")
     Set CheckBox1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("CheckBox1")
     Set CheckBox2 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("CheckBox2")

    TextBox1.Text = "TextBox1"
    TextBox1.Enabled = True
    TextBox1.Locked = False

    CheckBox1.Caption = "Enabled"
    CheckBox1.Value = True

    CheckBox2.Caption = "Locked"
    CheckBox2.Value = False

    TextBox2.Text = "TextBox2"
End Sub


EnterKeyBehavior Property Example

The following example uses the EnterKeyBehavior property to control the effect of ENTER in a TextBox. In this example, the user can specify either a single-line or multiline TextBox.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A TextBox named TextBox1.

  • Two ToggleButton controls named ToggleButton1 and ToggleButton2.
Dim TextBox1
Dim ToggleButton1
Dim ToggleButton2

Sub Item_Open()
    set TextBox1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("TextBox1")
    set ToggleButton1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("ToggleButton1")
    set ToggleButton2 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("ToggleButton2")
    TextBox1.EnterKeyBehavior = True
    ToggleButton1.Caption = "EnterKeyBehavior is True"
    ToggleButton1.Width = 70
    ToggleButton1.Value = True

    TextBox1.MultiLine = True
    ToggleButton2.Caption = "MultiLine is True"
    ToggleButton2.Width = 70
    ToggleButton2.Value = True

    TextBox1.Height = 100
    TextBox1.WordWrap = True
    TextBox1.Text = "Type your text here. If EnterKeyBehavior is True,"& _
    " press Enter to start a new line. Otherwise, press SHIFT+ENTER."
End Sub

Sub ToggleButton1_Click()
    If ToggleButton1.Value = True Then
        TextBox1.EnterKeyBehavior = True
        ToggleButton1.Caption = "EnterKeyBehavior is True"
    Else
        TextBox1.EnterKeyBehavior = False
        ToggleButton1.Caption = "EnterKeyBehavior is False"
    End If
End Sub

Sub ToggleButton2_Click()
    If ToggleButton2.Value = True Then
        TextBox1.MultiLine = True
        ToggleButton2.Caption = "MultiLine TextBox"
    Else
        TextBox1.MultiLine = False
        ToggleButton2.Caption = "Single-line TextBox"
    End If
End Sub


Int, Fix function examples

The following examples illustrate how the Int and Fix functions return integer portions of numbers. In the case of a negative number argument, the Int function returns the first negative integer less than or equal to the number; the Fix function returns the first negative integer greater than or equal to the number.

Function | Returns
Int(99.8) | 99
Fix(99.2) | 99
Int(-99.8) | -100
Fix (-99.8) | -99
Int(-99.2) | -100
Fix(-99.2) | -99


Format function example

This example shows various uses of the Format function to format values by using both named and user-defined formats. For the date separator (/), time separator (:), and AM/ PM literal, the actual formatted output displayed by your system depends on the locale settings on which the code is running. When displayed in a field, the short time and short date formats of the system locale are used, which may differ from the code locale. For these examples, English/United States is assumed.

Function | Returns
Format([Received], "h:m:s") | 17:4:23
Format([Received], "Long Time") | 17:4:23 PM
Format([Received], "Long Date") | Monday, January 27, 1997
Format([Received], "hh:mm:ss AMPM") | 05:04:23 PM
Format([Received], "dddd, mmm d yyyy") | Monday, Jan 27 1997

Function | Returns
Format(23) | 23
Format(5459.4, "##,##0.00") | 5,459.40
Format(334.9, "###0.00") | 334.90
Format(5, "0.00%") | 500.00%
Format("HELLO", "<") | hello
Format("This is it", ">") | THIS IS IT


FV function example

This example uses the FV function to return the future value of an investment given the percentage rate that accrues per period (APR / 12), the total number of payments (TotPmts), the payment (Payment), the current value of the investment (PVal), and a number that indicates whether the payment is made at the beginning or end of the payment period (PayType). Note that because Payment represents cash paid out, it's a negative number.

FV([APR] / 12, [TotPmts], -[Payment], -[PVal], [PayType])


GroupName Property Example

The following example uses the GroupName property to create two groups of OptionButton controls on the same form.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains five OptionButton controls named OptionButton1 through OptionButton5.

Sub Item_Open()
    set OptionButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton1")
    set OptionButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton2")
    set OptionButton3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton3")
    set OptionButton4 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton4")
    set OptionButton5 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton5")

    OptionButton1.Caption = "Widgets"
    OptionButton2.Caption = "Widgets"
    OptionButton3.Caption = "Widgets"
    OptionButton1.GroupName = "Widgets"
    OptionButton2.GroupName = "Widgets"
    OptionButton3.GroupName = "Widgets"

    OptionButton4.Caption = "Gadgets-Group2"
    OptionButton5.Caption = "Gadgets-Group2"
    OptionButton4.GroupName = "Gadgets-Group2"
    OptionButton5.GroupName = "Gadgets-Group2"
End Sub


Hex function example

The following examples use the Hex function to return the hexadecimal value of values for the Number field.

Number field | Function returns
5 | 5
10 | A
459 | 1CB

Hex([Number])


Hour function example

The following example uses the Hour function to return the hour of the Received field.

Hour([Received])


IIf function example

The following example uses the IIf function to return the word "Large" if the value of the Size field is greater than 10000; otherwise, it returns the word "Small".

IIf([Size] > 10000, "Large", "Small")


Index Property Example

The following example uses the Index property to change the order of the pages and tabs in a MultiPage and TabStrip. The user chooses CommandButton1 to move the third page and tab to the front of the MultiPage and TabStrip. The user chooses CommandButton2 to move the selected page and tab to the back of the MultiPage and TabStrip.

To use this example, copy this sample code to the Script Editor of a form. Make sure that the form contains:

  • Two CommandButton controls named CommandButton1 and CommandButton2.

  • A MultiPage named MultiPage1.

  • A TabStrip named TabStrip1.
Dim MyPageOrTab
Dim MultiPage1
Dim TabStrip1

Sub CommandButton1_Click()
'Move third page and tab to front of control
    MultiPage1.page3.Index = 0
    TabStrip1.Tab3.Index = 0
End Sub

Sub CommandButton2_Click()
'Move selected page and tab to back of control
    Set MyPageOrObject = MultiPage1.SelectedItem
    MsgBox "MultiPage1.SelectedItem = " & MultiPage1.SelectedItem.Name
    MyPageOrObject.Index = 4

    Set MyPageOrObject = TabStrip1.SelectedItem
    MsgBox "TabStrip1.SelectedItem = " & TabStrip1.SelectedItem.Caption
    MyPageOrObject.Index = 4
End Sub

Sub Item_Open()
     Set MultiPage1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("MultiPage1")
     Set TabStrip1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("TabStrip1")
     Set CommandButton1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("CommandButton1")
     Set CommandButton2 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("CommandButton2")

    MultiPage1.Width = 200
    MultiPage1.Pages.Add
    MultiPage1.Pages.Add
    MultiPage1.Pages.Add

    TabStrip1.Width = 200
    TabStrip1.Tabs.Add
    TabStrip1.Tabs.Add
    TabStrip1.Tabs.Add

    CommandButton1.Caption = "Move third page/tab to front"
    CommandButton1.Width = 120

    CommandButton2.Caption = "Move selected item to back"
    CommandButton2.Width = 120
 End Sub


InsideHeight, InsideWidth Properties Example

The following example uses the InsideHeight and InsideWidth properties to resize a CommandButton. The user clicks the CommandButton to resize it.

Note InsideHeight and InsideWidth are read-only properties.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A CommandButton named CommandButton1.
Dim Resize

Sub Item_Open()
    Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CommandButton1")

    Resize = 0.75
    CommandButton1.Caption = "Resize Button"

End Sub

Sub CommandButton1_Click()
    Set Form = Item.GetInspector.ModifiedFormPages("P.2")
    Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CommandButton1")

    CommandButton1.Move 10, 10, Form.InsideWidth * Resize, Form.InsideHeight * Resize
    CommandButton1.Caption = "Button resized using InsideHeight and InsideWidth!"
End Sub


InStr function example

The following example uses the InStr function to return the position of the first occurrence of the letter S within the Subject field.

Subject field | Function returns
International Sales | 11
Marketing Strategy | 15

InStr(1, [Subject], "S", 1)


IPmt function example

This example uses the IPmt function to calculate how much of a payment is interest when all the payments are of equal value. Given are the interest percentage rate per period (APR / 12), the payment period for which the interest portion is desired (Period), the total number of payments (TotPmts), the present value or principal of the loan (PVal), the future value of the loan (FVal), and a number that indicates whether the payment is due at the beginning or end of the payment period (PayType).

IPmt([APR] / 12, [Period], [TotPmts], -[PVal], [FVal], [PayType])


IsDate function example

The following example uses the IsDate function to determine whether the Other field can be converted to a date.

IsDate([Other])


Item Method Example

The following example uses the Item method to access individual members of the Controls and Pages collections. The user chooses an option button for either the Controls collection or the MultiPage, and then clicks the CommandButton. The name of the appropriate control is returned in the Label.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A CommandButton named CommandButton1.

  • A Label named Label1.

  • Two OptionButton controls named OptionButton1 and OptionButton2.

  • A MultiPage named MultiPage1.
Dim ControlsIndex

Sub CommandButton1_Click()
    Set Controls = Item.GetInspector.ModifiedFormPages("P.2").Controls
    Set OptionButton1 = Controls("OptionButton1")
    Set OptionButton2 = Controls("OptionButton2")
    Set Label1 = Controls("Label1")
    Set MultiPage1 = Controls("MultiPage1")

    If OptionButton1.Value = True Then
        'Process Controls collection for UserForm
        Set MyControl = Controls.Item(ControlsIndex)
        Label1.Caption = MyControl.Name

        'Prepare index for next control on Userform
        ControlsIndex = ControlsIndex + 1
        If ControlsIndex >= Controls.Count Then
            ControlsIndex = 0
        End If

    ElseIf OptionButton2.Value = True Then
        'Process Current Page of Pages collection
        Set MyControl = MultiPage1.Pages.Item(MultiPage1.Value)
        Label1.Caption = MyControl.Name
    End If
End Sub

Sub Item_Open()
    ControlsIndex = 0

    Set OptionButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton1")
    Set OptionButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton2")
    Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CommandButton1")

    OptionButton1.Caption = "Controls Collection"
    OptionButton2.Caption = "Pages Collection"
    OptionButton1.Value = True

    CommandButton1.Caption = "Get Member Name"
End Sub


LargeChange, SmallChange Properties Example

The following example demonstrates the LargeChange and SmallChange properties when used with a stand-alone ScrollBar. The user can set the LargeChange and SmallChange values to any integer in the range of 0 to 100. This example also uses the MaxLength property to restrict the number of characters entered for the LargeChange and SmallChange values.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A Label named Label1

  • A TextBox named TextBox1 that is bound to the custom number field named ScrollBarSmallChange

  • A Label named Label2

  • A TextBox named TextBox2 that is bound to the custom number field named ScrollBarLargeChange.

  • A ScrollBar named ScrollBar1 that is bound to the custom number field named ScrollBarValue.

  • A Label named Label3.
Sub Item_Open()
    Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label1")
    Set ScrollBar1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ScrollBar1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set Label2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label2")
    Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox2")
    Set Label3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label3")

    ScrollBar1.Min = -1000
    ScrollBar1.Max = 1000

    Label1.Caption = "SmallChange 0 to 100"
    ScrollBar1.SmallChange = 1
    TextBox1.Text = ScrollBar1.SmallChange
    TextBox1.MaxLength = 3

    Label2.Caption = "LargeChange 0 to 100"
    ScrollBar1.LargeChange = 100
    TextBox2.Text = ScrollBar1.LargeChange
    TextBox2.MaxLength = 3

    ScrollBar1.Value = 0
    Label3.Caption = ScrollBar1.Value
End Sub

Sub Item_CustomPropertyChange(byval pname)
    Set ScrollBar1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ScrollBar1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox2")
    Set Label3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label3")

    If pname = "ScrollBarMin" Then

        If IsNumeric(TextBox1.Text) Then
            TempNum = CInt(TextBox1.Text)
            If TempNum >= 0 And TempNum <= 100 Then
                ScrollBar1.SmallChange = TempNum
            Else
                TextBox1.Text = ScrollBar1.SmallChange
            End If
        Else
            TextBox1.Text = ScrollBar1.SmallChange
        End If

    ElseIf pname = "ScrollBarMax" Then

        If IsNumeric(TextBox2.Text) Then
            TempNum = CInt(TextBox2.Text)
            If TempNum >= 0 And TempNum <= 100 Then
                ScrollBar1.LargeChange = TempNum
            Else
                TextBox2.Text = ScrollBar1.LargeChange
            End If
        Else
            TextBox2.Text = ScrollBar1.LargeChange
        End If

    ElseIf pname = "ScrollBarValue" Then

        Label3.Caption = ScrollBar1.Value
    End If
End Sub


LCase function example

The following example returns lowercase values of the Subject field.

Subject field | Function returns
International Sales | international sales
Marketing Strategy | marketing strategy

LCase([Subject])


Left function example

The following example returns four characters from the left side of the Subject field.

Subject field | Function returns
International Sales | Inte
Marketing Strategy | Mark

Left([Subject], 4)


Len function example

The following example uses the Len function to return the number of characters in the Subject field.

Subject field | Function returns
International Sales | 19
Marketing Strategy | 18

Len([Subject])


LineCount, TextLength Properties Example

The following example counts the characters and the number of lines of text in a TextBox by using the LineCount and TextLength properties, and the SetFocus method. In this example, the user can type into a TextBox, and can retrieve current values of the LineCount and TextLength properties.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains the following controls:

  • A TextBox named TextBox1.

  • A CommandButton named CommandButton1.

  • Two Label controls named Label1 and Label2.
'Type SHIFT+ENTER to start a new line in the text box.

Dim CommandButton1
Dim TextBox1
Dim Label1
Dim Label2

Sub CommandButton1_Click()
    'Must first give TextBox1 the focus to get line count
    TextBox1.SetFocus
    Label1.Caption = "LineCount = " & TextBox1.LineCount
    Label2.Caption = "TextLength = " & TextBox1.TextLength
End Sub

Sub Item_Open()
     Set TextBox1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("TextBox1")
     Set Label1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("Label1")
     Set Label2 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("Label2")
     Set CommandButton1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("CommandButton1")

    CommandButton1.WordWrap = True
    CommandButton1.AutoSize = True
    CommandButton1.Caption = "Get Counts"

    Label1.Caption = "LineCount = "
    Label2.Caption = "TextLength = "

    TextBox1.MultiLine = True
    TextBox1.WordWrap = True
    TextBox1.Text = "Enter your text here."
End Sub


ListBox Control Example

The following example adds and deletes the contents of a ListBox using the AddItem, RemoveItem, and SetFocus methods, and the ListIndex and ListCount properties.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A ListBox named ListBox1.

  • Two CommandButton controls named CommandButton1 and CommandButton2.
Dim EntryCount
Dim Listbox1

Sub Item_Open()
  Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").ListBox1
  Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").CommandButton1
  Set CommandButton2 = Item.GetInspector.ModifiedFormPages("P.2").CommandButton2
  EntryCount = 0
  CommandButton1.Caption = "Add Item"
  CommandButton2.Caption = "Remove Item"
End Sub

Sub CommandButton1_Click()
  EntryCount = EntryCount + 1
  ListBox1.AddItem (EntryCount & " - Selection")
End Sub

Sub CommandButton2_Click()
  ListBox1.SetFocus

  'Ensure ListBox contains list items
  If ListBox1.ListCount >= 1 Then
      'If no selection, choose last list item.
      If ListBox1.ListIndex = -1 Then
          ListBox1.ListIndex = ListBox1.ListCount - 1
      End If
      ListBox1.RemoveItem (ListBox1.ListIndex)
  End If
End Sub


List Property Example

The following example swaps columns of a multicolumn ListBox. The sample uses the List property in two ways:

  1. To access and exchange individual values in the ListBox. In this usage, List has subscripts to designate the row and column of a specified value.

  2. To initially load the ListBox with values from an array. In this usage, List has no subscripts.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains a ListBox named ListBox1 and a CommandButton named CommandButton1.

Dim Listbox1
Dim MyArray(6, 3)

Sub Item_Open
  Dim i
  Set Listbox1 = Item.GetInspector.ModifiedFormPages("P.2").Listbox1

  Listbox1.ColumnCount = 3
  For i = 0 to 5
    MyArray(i, 0) = i
    MyArray(i, 1) = Rnd
    MyArray(i, 2) = Rnd
  Next

  Listbox1.List() = MyArray
End Sub

Sub CommandButton1_Click
  Dim i
  Dim Temp

  For i = 0 to 5
    Temp = Listbox1.List(i, 0)
    Listbox1.List(i, 0) = Listbox1.List(i, 2)
    Listbox1.List(i, 2) = Temp
  Next
End Sub


ListRows Property Example

The following example uses a SpinButton to control the number of rows in the drop-down list of a ComboBox. The user changes the value of the SpinButton, then clicks on the drop-down arrow of the ComboBox to display the list.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A ComboBox named ComboBox1.

  • A SpinButton named SpinButton1 that is bound to a custom number field named SpinButtonValue.

  • A Label named Label1.
Sub Item_Open()
    Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
    Set SpinButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("SpinButton1")
    Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label1")

    For i = 1 To 20
        ComboBox1.AddItem "Choice " & (ComboBox1.ListCount + 1)
    Next

    SpinButton1.Min = 0
    SpinButton1.Max = 12
    SpinButton1.Value = ComboBox1.ListRows
    Label1.Caption = "ListRows = " & SpinButton1.Value
End Sub

Sub Item_CustomPropertyChange(byval pname)
    If pname = "SpinButtonValue" Then
        Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
        Set SpinButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("SpinButton1")
        Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label1")

            ComboBox1.ListRows = SpinButton1.Value
        Label1.Caption = "ListRows = " & SpinButton1.Value
    End If
End Sub


ListStyle, MultiSelect Properties Example

The following example uses the ListStyle and MultiSelect properties to control the appearance of a ListBox. The user chooses a value for ListStyle using the ToggleButton and chooses an OptionButton for one of the MultiSelect values. The appearance of the ListBox changes accordingly, as well as the selection behavior within the ListBox.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A ListBox named ListBox1.

  • A Label named Label1.

  • Three OptionButton controls named OptionButton1 through OptionButton3.

  • A ToggleButton named ToggleButton1.
Sub Item_Open()
    Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox1")
    Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label1")
    Set OptionButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton1")
    Set OptionButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton2")
    Set OptionButton3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton3")
    Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton1")

    For i = 1 To 8
        ListBox1.AddItem "Choice" & (ListBox1.ListCount + 1)
    Next

    Label1.Caption = "MultiSelect Choices"
    Label1.AutoSize = True

    ListBox1.MultiSelect = 0        '0=fmMultiSelectSingle
    OptionButton1.Caption = "Single entry"
    OptionButton1.Value = True
    OptionButton2.Caption = "Multiple entries"
    OptionButton3.Caption = "Extended entries"

    ToggleButton1.Caption = "ListStyle - Plain"
    ToggleButton1.Value = True
    ToggleButton1.Width = 90
    ToggleButton1.Height = 30
End Sub

Sub OptionButton1_Click()
    Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox1")
    ListBox1.MultiSelect = 0        '0=fmMultiSelectSingle
End Sub

Sub OptionButton2_Click()
    Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox1")
    ListBox1.MultiSelect = 1        '1=fmMultiSelectMulti
End Sub

Sub OptionButton3_Click()
    Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox1")
    ListBox1.MultiSelect = 2        '2=fmMultiSelectExtended
End Sub

Sub ToggleButton1_Click()
    Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton1")
    Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox1")

    If ToggleButton1.Value = True Then
        ToggleButton1.Caption = "Plain ListStyle"
        ListBox1.ListStyle = 0    '0=fmListStylePlain
    Else
        ToggleButton1.Caption = "OptionButton or CheckBox"
        ListBox1.ListStyle = 1    '1=fmListStyleOption
    End If
End Sub


ListWidth Property Example

The following example uses a SpinButton to control the width of the drop-down list of a ComboBox. The user changes the value of the SpinButton, then clicks on the drop-down arrow of the ComboBox to display the list.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A ComboBox named ComboBox1.

  • A SpinButton named SpinButton1 that is bound to a custom number field named SpinButtonValue.

  • A Label named Label1.
Sub Item_Open()
    Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
    Set SpinButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("SpinButton1")
    Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label1")

    For i = 1 To 20
        ComboBox1.AddItem "Choice " & (ComboBox1.ListCount + 1)
    Next
    SpinButton1.Min = 0
    SpinButton1.Max = 130

    'convert listwidth value from '122 pt' to an integer
    intpos = instr(combobox1.listwidth," ")
    intwidth = left(combobox1.listwidth,intpos-1)
    SpinButton1.Value = intwidth
    SpinButton1.SmallChange = 5
    Label1.Caption = "ListWidth = " & SpinButton1.Value
End Sub

Sub Item_CustomPropertyChange(byval pname)
    If pname = "SpinButtonValue" Then
        Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
        Set SpinButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("SpinButton1")
        Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label1")

    ComboBox1.ListWidth = SpinButton1.Value
    Label1.Caption = "ListWidth = " & SpinButton1.Value
    End If
End Sub


Log function example

The following example returns the natural logarithm for the numeric field Angle.

Log([Angle] + Sqr([Angle] * [Angle] + 1))


LTrim, RTrim, and Trim function examples

The following examples use the LTrim and RTrim functions to strip leading and trailing spaces, respectively, from a Subject field that contains the value " <-Trim-> ". It uses the Trim function alone to strip both types of spaces. The quotation marks mark the end of the string but are not part of it.

Function | Returns
LTrim([Subject]) | "<-Trim-> "
RTrim([Subject]) | " <-Trim->"
Trim([Subject]) | "<-Trim->"


MatchEntry Property Example

The following example uses the MatchEntry property to demonstrate character matching that is available for ComboBox and ListBox. In this example, the user can set the type of matching with the OptionButton controls and then type into the ComboBox to specify an item from its list.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • Three OptionButton controls named OptionButton1 through OptionButton3.

  • A ComboBox named ComboBox1.
Sub OptionButton1_Click()
    Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
    ComboBox1.MatchEntry = 2        '2=fmMatchEntryNone
End Sub

Sub OptionButton2_Click()
    Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
    ComboBox1.MatchEntry = 0        '0=fmMatchEntryFirstLetter
End Sub

Sub OptionButton3_Click()
    Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
        ComboBox1.MatchEntry = 1    '1=fmMatchEntryComplete
End Sub

Sub Item_Open()
    Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
    Set OptionButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton1")
    Set OptionButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton2")
    Set OptionButton3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton3")

    For i = 1 To 9
        ComboBox1.AddItem "Choice " & i
    Next
    ComboBox1.AddItem "Chocoholic"

    OptionButton1.Caption = "No matching"
    OptionButton1.Value = True

    OptionButton2.Caption = "Basic matching"
    OptionButton3.Caption = "Extended matching"
End Sub


MatchFound, MatchRequired Properties Example

The following example uses the MatchFound and MatchRequired properties to demonstrate additional character matching for ComboBox. The matching verification occurs in the Change event.

In this example, the user specifies whether the text portion of a ComboBox must match one of the listed items in the ComboBox. The user can specify whether matching is required by using a CheckBox and then type into the ComboBox to specify an item from its list.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A ComboBox named ComboBox1 that is bound to the Subject field.

  • A CheckBox named CheckBox1.
Sub CheckBox1_Click()
    Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
    Set CheckBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CheckBox1")

    If CheckBox1.Value = True Then
        ComboBox1.MatchRequired = True
        MsgBox "To move the focus from the ComboBox, you must match an entry in the list or press ESC."
    Else
        ComboBox1.MatchRequired = False
        MsgBox " To move the focus from the ComboBox, just tab to or click another control. Matching is optional."
    End If
End Sub

Sub Item_PropertyChange(byval pname)
    if pname = "Subject" then
        Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
        If ComboBox1.MatchRequired = True Then
        'MSForms handles this case automatically
        Else
            If ComboBox1.MatchFound = True Then
                MsgBox "Match Found; matching optional."
            Else
                MsgBox "Match not Found; matching optional."
            End If
        End If
    end if
End Sub

Sub Item_Open()
    Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
    Set CheckBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CheckBox1")

    For i = 1 To 9
            ComboBox1.AddItem "Choice " & i
    Next
    ComboBox1.AddItem "Chocoholic"

    CheckBox1.Caption = "MatchRequired"
    CheckBox1.Value = True
End Sub


Max, Min, MaxLength Properties Example

The following example demonstrates the Max and Min properties when used with a stand-alone ScrollBar. The user can set the Max and Min values to any integer in the range of –1000 to 1000. This example also uses the MaxLength property to restrict the number of characters entered for the Max and Min values.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A Label named Label1

  • A TextBox named TextBox1 that is bound to the custom number field named ScrollBarMin.

  • A Label named Label2

  • A TextBox named TextBox2 that is bound to the custom number field named ScrollBarMax.

  • A ScrollBar named ScrollBar1 that is bound to the custom number field named ScrollBarValue.

  • A Label named Label3.
Sub Item_Open()
    Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label1")
    Set ScrollBar1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ScrollBar1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set Label2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label2")
    Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox2")
    Set Label3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label3")

    Label1.Caption = "Min -1000 to 1000"
    ScrollBar1.Min = -1000
    TextBox1.Text = ScrollBar1.Min
    TextBox1.MaxLength = 5

    Label2.Caption = "Max -1000 to 1000"
    ScrollBar1.Max = 1000
    TextBox2.Text = ScrollBar1.Max
    TextBox2.MaxLength = 5

    ScrollBar1.SmallChange = 1
    ScrollBar1.LargeChange = 100
    ScrollBar1.Value = 0
    Label3.Caption = ScrollBar1.Value
End Sub

Sub Item_CustomPropertyChange(byval pname)
    Set ScrollBar1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ScrollBar1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox2")
    Set Label3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label3")

    If pname = "ScrollBarMin" Then

        If IsNumeric(TextBox1.Text) Then
                TempNum = CInt(TextBox1.Text)
            If TempNum >= -1000 And TempNum <= 1000 Then
                    ScrollBar1.Min = TempNum
                Else
                    TextBox1.Text = ScrollBar1.Min
            End If
            Else
                TextBox1.Text = ScrollBar1.Min
        End If
    ElseIf pname = "ScrollBarMax" Then

        If IsNumeric(TextBox2.Text) Then
                TempNum = CInt(TextBox2.Text)
                If TempNum >= -1000 And TempNum <= 1000 Then
                    ScrollBar1.Max = TempNum
            Else
                    TextBox2.Text = ScrollBar1.Max
                End If
        Else
                TextBox2.Text = ScrollBar1.Max
        End If
    ElseIf pname = "ScrollBarValue" Then

        Label3.Caption = ScrollBar1.Value
    End If
End Sub


Mid function example

The following example uses the Mid function to return a specified number of characters from the Subject field with the value "Marketing Strategy".

Function | Returns
Mid ([Subject], 1, 3) | Mar
Mid ([Subject], 11, 8) | Strategy
Mid ([Subject], 5) | eting Strategy


Minute function example

The following example uses the Minute function to return the minute of the Received field.

Minute([Received])


Month function example

The following example uses the Month function to return the month of the Received field.

Month([Received])


MouseIcon, MousePointer Properties Example

The following example demonstrates how to specify a mouse pointer that is appropriate for a specific control or situation. You can assign one of several available mouse pointers using the MousePointer property.

This example works in the following ways:

  • Choose a mouse pointer from the ListBox to change the mouse pointer associated with the ListBox.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A ListBox named ListBox1.
Dim ListBox1

Sub Item_Open()
    set ListBox1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("ListBox1")
    'Load ListBox with MousePointer choices
    ListBox1.Clear
    ListBox1.AddItem "Default"
    ListBox1.AddItem "Arrow"
    ListBox1.AddItem "Cross"
    ListBox1.AddItem "IBeam"
    ListBox1.AddItem "SizeNESW"
    ListBox1.AddItem "SizeNS"
    ListBox1.AddItem "SizeNWSE"
    ListBox1.AddItem "SizeWE"
    ListBox1.AddItem "UpArrow"
    ListBox1.AddItem "Hourglass"
    ListBox1.AddItem "NoDrop"
    ListBox1.AddItem "AppStarting"
    ListBox1.AddItem "Help"
    ListBox1.AddItem "SizeAll"
End Sub

Sub ListBox1_Click()
   If IsNull(ListBox1.Value) = False Then
    Select Case ListBox1.Value
        Case "Default"
            pointer = 0        'Standard pointer.
            Case "Arrow"
            pointer = 1        'Arrow.
        Case "Cross"
            pointer = 2        'Cross-hair pointer.
        Case "IBeam"
            pointer = 3        'I-beam.
        Case "SizeNESW"
            pointer = 6        'Double arrow pointing northeast and southwest.
        Case "SizeNS"
            pointer = 7        'Double arrow pointing north and south.
         Case "SizeNWSE"
            pointer = 8        'Double arrow pointing northwest and southeast.
        Case "SizeWE"
            pointer = 9        'Double arrow pointing west and east.
        Case "UpArrow"
            pointer = 10    'Up arrow.
        Case "Hourglass"
            pointer = 11    'Hourglass.
        Case "NoDrop"
            pointer = 12    '"Not" symbol (circle with a diagonal line) on top of the object being dragged. Indicates an invalid drop target.
        Case "AppStarting"
            pointer = 13    'Arrow with an hourglass.
        Case "Help"
            pointer = 14    'Arrow with a question mark.
        Case "SizeAll"
            pointer = 15    'Size all cursor (arrows pointing north, south, east, and west).
    End Select
    ListBox1.MousePointer = pointer
   End If
End Sub


Move Method Example for Controls Collection

The following example demonstrates moving all the controls on a form by using the Move method with the Controls collection. The user clicks on the CommandButton to move the controls.

To use this example, copy this sample code to the Script Editor of a form. Make sure that the form contains a CommandButton named CommandButton1 and several other controls.

Sub CommandButton1_Click()
  Set Controls = Item.GetInspector.ModifiedFormPages("P.2").Controls
  'Move each control on the form right 25 points and up 25 points.
  Controls.Move 25, -25
End Sub


MultiLine, WordWrap, ScrollBars Properties Example

The following example demonstrates the MultiLine, WordWrap, and ScrollBars properties on a TextBox.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A TextBox named TextBox1.

  • Four ToggleButton controls named ToggleButton1 through ToggleButton4.

To see the entire text placed in the TextBox, set MultiLine and WordWrap to True by clicking the ToggleButton controls.

When MultiLine is True, you can enter new lines of text by pressing SHIFT+ENTER.

ScrollBars appears when you manually change the content of the TextBox.

Dim ToggleButton1
Dim ToggleButton2
Dim ToggleButton3
Dim ToggleButton4
Dim TextBox1

Sub Item_Open
'Initialize TextBox properties and toggle buttons

  Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").ToggleButton1
  Set ToggleButton2 = Item.GetInspector.ModifiedFormPages("P.2").ToggleButton2
  Set ToggleButton3 = Item.GetInspector.ModifiedFormPages("P.2").ToggleButton3
  Set ToggleButton4 = Item.GetInspector.ModifiedFormPages("P.2").ToggleButton4
  Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").TextBox1

  TextBox1.Text = "Type your text here.  Enter SHIFT+ENTER to move to a new line."
  TextBox1.AutoSize = False
  ToggleButton1.Caption = "AutoSize Off"
  ToggleButton1.Value = False
  ToggleButton1.AutoSize = True

  TextBox1.WordWrap = False
  ToggleButton2.Caption = "WordWrap Off"
  ToggleButton2.Value = False
  ToggleButton2.AutoSize = True

  TextBox1.ScrollBars = 0
  ToggleButton3.Caption = "ScrollBars Off"
  ToggleButton3.Value = False
  ToggleButton3.AutoSize = True

  TextBox1.MultiLine = False
  ToggleButton4.Caption = "Single Line"
  ToggleButton4.Value = False
  ToggleButton4.AutoSize = True

End Sub

Sub ToggleButton1_Click
'Set AutoSize property and associated ToggleButton

  If ToggleButton1.Value = True Then
    TextBox1.AutoSize = True
    ToggleButton1.Caption = "AutoSize On"
  Else
    TextBox1.AutoSize = False
    ToggleButton1.Caption = "AutoSize Off"
  End if
End Sub

Sub ToggleButton2_Click
'Set WordWrap property and associated  ToggleButton

  If ToggleButton2.Value = True Then
    TextBox1.WordWrap = True
    ToggleButton2.Caption = "WordWrap On"
  Else
    TextBox1.WordWrap = False
    ToggleButton2.Caption = "WordWrap Off"
  End if
End Sub

Sub ToggleButton3_Click
'Set ScrollBars property and associated ToggleButton

  If ToggleButton3.Value = True Then
    TextBox1.ScrollBars = 3
    ToggleButton3.Caption = "ScrollBars On"
  Else
    TextBox1.ScrollBars = 0
    ToggleButton3.Caption = "ScrollBars Off"
  End if
End Sub

Sub ToggleButton4_Click
'Set MultiLine property and associated ToggleButton

  If ToggleButton4.Value = True Then
    TextBox1.MultiLine = True
    ToggleButton4.Caption = "Multiple Lines"
  Else
    TextBox1.MultiLine = False
    ToggleButton4.Caption = "Single Line"
  End if
 End Sub


MultiSelect, Selected Properties Example

The following example uses the MultiSelect and Selected properties to demonstrate how the user can select one or more items in a ListBox. The user specifies a selection method by choosing an option button and then selects an item(s) from the ListBox. The user can display the selected items in a second ListBox by clicking the CommandButton.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • Two ListBox controls named ListBox1 and ListBox2.

  • A CommandButton named CommandButton1.

  • Three OptionButton controls named OptionButton1 through OptionButton3.
Sub CommandButton1_Click()
    Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox1")
    Set ListBox2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox2")
    ListBox2.Clear

    For i = 0 To 9
        If ListBox1.Selected(i) = True Then
            ListBox2.AddItem ListBox1.List(i)
        End If
    Next

End Sub

Sub OptionButton1_Click()
    Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox1")
    ListBox1.MultiSelect = 0        '0=fmMultiSelectSingle
End Sub

Sub OptionButton2_Click()
    Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox1")
    ListBox1.MultiSelect = 1        '1=fmMultiSelectMulti
End Sub

Sub OptionButton3_Click()
    Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox1")
    ListBox1.MultiSelect = 2        '2=fmMultiSelectExtended
End Sub

Sub Item_Open()
    Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox1")
    Set OptionButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton1")
    Set OptionButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton2")
    Set OptionButton3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton3")
    Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CommandButton1")

    For i = 0 To 9
        ListBox1.AddItem "Choice " & (ListBox1.ListCount + 1)
    Next

    OptionButton1.Caption = "Single Selection"
    ListBox1.MultiSelect = 0        '0=fmMultiSelectSingle
    OptionButton1.Value = True

    OptionButton2.Caption = "Multiple Selection"
    OptionButton3.Caption = "Extended Selection"

    CommandButton1.Caption = "Show selections"
    CommandButton1.AutoSize = True
End Sub


 Name Property Example

Name Property Example

The following example displays the Name property of each control on a form. This example uses the Controls collection to cycle through all the controls placed directly on the User form.

To use this example, copy this sample code to the Script Editor of a form. Make sure that the form contains a CommandButton named CommandButton1 and several other controls.

Sub CommandButton1_Click()
    Set Controls = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls
    For i = 0 to Controls.Count - 1
        MsgBox "MyControl.Name = " & Controls.Item(i).Name
    Next
End Sub


Now function example

The following example uses the Now function to return the number of days since an item was received.

DateValue(Now())-DateValue([Received]) & " Day(s)"


NPer function example

This example uses the NPer function to return the number of periods over which payments must be made to pay off a loan whose value is contained in PVal. Also provided are the interest percentage rate per period (APR / 12), the payment (Payment), the future value of the loan (FVal), and a number that indicates whether the payment is due at the beginning or end of the payment period (PayType).

IPmt([APR] / 12, [Period], [TotPmts], -[PVal], [FVal], [PayType])


Object Property Example

Assume a new control has a Top property that is different from the standard Top property in Microsoft Forms. You can use either property, based on the syntax:

  • control.Top uses the standard Top property.

  • control.Object.Top uses the Top property from the added control.


Oct function example

The following examples use the Oct function to return the octal value of values for the Number field.

Number field | Function returns
4 | 4
8 | 10
459 | 713

Oct([Number])


Parent Property Example

The following example uses the Parent property to refer to the control or form that contains a specific control.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • Two Label controls named Label1 and Label2.

  • A CommandButton named CommandButton1.

  • One or more additional controls of your choice.
Dim MyControl
Dim MyParent
Dim ControlsIndex

Sub Item_Open()
  Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").CommandButton1
  ControlsIndex = 0
  CommandButton1.Caption = "Get Control and Parent"
  CommandButton1.AutoSize = True
  CommandButton1.WordWrap = True
End Sub

Sub CommandButton1_Click()
  Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Label1
  Set Label2 = Item.GetInspector.ModifiedFormPages("P.2").Label2

  'Process Controls collection for UserForm
  Set MyControl = Item.GetInspector.ModifiedFormPages("P.2").Controls.Item(ControlsIndex)
  Set MyParent = MyControl.Parent
  Label1.Caption = MyControl.Name
  Label2.Caption = MyParent.Name

  'Prepare index for next control on Userform
  ControlsIndex = ControlsIndex + 1
  If ControlsIndex >= Item.GetInspector.ModifiedFormPages("P.2").Controls.Count Then
    ControlsIndex = 0
  End If
End Sub


Picture, PicturePosition Properties Example

The following example uses a ComboBox to show the picture placement options for a control. Each time the user clicks a list choice, the picture and caption are updated on the CommandButton. This code sample also uses the AddItem method to populate the ComboBox choices.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A Label named Label1.

  • A CommandButton named CommandButton1 with the Picture property set to use an image on your computer.

  • A ComboBox named ComboBox1.
Dim Label1
Dim CommandButton1
Dim ComboBox1

Sub Item_Open()
Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Label1
Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").CommandButton1
Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").ComboBox1

    Label1.Left = 18
    Label1.Top = 12
    Label1.Height = 12
    Label1.Width = 190
    Label1.Caption = "Select picture placement relative to the caption."

    'Add list entries to combo box. The value of each entry matches the
    'corresponding ListIndex value in the combo box.
    ComboBox1.AddItem "Left Top"        'ListIndex = 0
    ComboBox1.AddItem "Left Center"     'ListIndex = 1
    ComboBox1.AddItem "Left Bottom"     'ListIndex = 2
    ComboBox1.AddItem "Right Top"       'ListIndex = 3
    ComboBox1.AddItem "Right Center"    'ListIndex = 4
    ComboBox1.AddItem "Right Bottom"    'ListIndex = 5

    ComboBox1.AddItem "Above Left"      'ListIndex = 6
    ComboBox1.AddItem "Above Center"    'ListIndex = 7
    ComboBox1.AddItem "Above Right"    'ListIndex = 8
    ComboBox1.AddItem "Below Left"      'ListIndex = 9
    ComboBox1.AddItem "Below Center"    'ListIndex = 10
    ComboBox1.AddItem "Below Right"    'ListIndex = 11

    ComboBox1.AddItem "Centered"        'ListIndex = 12

    ComboBox1.Style = 2  'Use drop-down list

    ComboBox1.BoundColumn = 0            'Combo box values are ListIndex values
    ComboBox1.ListIndex = 0              'Set combo box to first entry

    ComboBox1.Left = 18
    ComboBox1.Top = 36
    ComboBox1.Width = 90
    ComboBox1.ListWidth = 90

    'Initialize CommandButton1
    CommandButton1.Left = 230
    CommandButton1.Top = 36
    CommandButton1.Height = 120
    CommandButton1.Width = 120

    'Note: Be sure to refer to have set the CommandButton1 to a bitmap file
      'Note: that is present on your system
    CommandButton1.PicturePosition = ComboBox1.Value
End Sub

Sub ComboBox1_Click()
    Select Case ComboBox1.Value
    Case 0  'Left Top
        CommandButton1.Caption = "Left Top"
        CommandButton1.PicturePosition = 0

    Case 1  'Left Center
        CommandButton1.Caption = "Left Center"
        CommandButton1.PicturePosition = 1

    Case 2  'Left Bottom
        CommandButton1.Caption = "Left Bottom"
        CommandButton1.PicturePosition = 2

    Case 3  'Right Top
        CommandButton1.Caption = "Right Top"
        CommandButton1.PicturePosition = 3

    Case 4  'Right Center
        CommandButton1.Caption = "Right Center"
        CommandButton1.PicturePosition = 4

    Case 5  'Right Bottom
        CommandButton1.Caption = "Right Bottom"
        CommandButton1.PicturePosition = 5

    Case 6  'Above Left
        CommandButton1.Caption = "Above Left"
        CommandButton1.PicturePosition = 6

    Case 7  'Above Center
        CommandButton1.Caption = "Above Center"
        CommandButton1.PicturePosition = 7

    Case 8  'Above Right
        CommandButton1.Caption = "Above Right"
        CommandButton1.PicturePosition = 8

    Case 9  'Below Left
        CommandButton1.Caption = "Below Left"
        CommandButton1.PicturePosition = 9

    Case 10 'Below Center
        CommandButton1.Caption = "Below Center"
        CommandButton1.PicturePosition = 10

    Case 11 'Below Right
        CommandButton1.Caption = "Below Right"
        CommandButton1.PicturePosition = 11

    Case 12 'Centered
        CommandButton1.Caption = "Centered"
        CommandButton1.PicturePosition = 12

    End Select

End Sub


Pmt function example

This example uses the Pmt function to return the payment for a loan over a fixed period. Given are the interest percentage rate per period (APR / 12), the total number of payments (TotPmts), the present value or principal of the loan (PVal), the future value of the loan (FVal), and a number that indicates whether the payment is due at the beginning or end of the payment period (PayType).

Pmt([APR] / 12, [TotPmts], -[PVal], [FVal], [PayType])


PPmt function example

This example uses the PPmt function to calculate how much of a payment for a specific period is principal when all the payments are of equal value. Given are the interest percentage rate per period (APR / 12), the payment period for which the principal portion is desired (Period), the total number of payments (TotPmts), the present value or principal of the loan (PVal), the future value of the loan (FVal), and a number that indicates whether the payment is due at the beginning or end of the payment period (PayType).

PPmt([APR] / 12, [Period], [TotPmts], -[PVal], [FVal], [PayType])


PV function example

In this example, the PV function returns the present value of an annuity given the expected annual percentage rate (APR), the total number of payments (TotPmts), the amount of each payment (YrIncome), the total future value of the investment (FVal), and a number that indicates whether each payment is made at the beginning or end of the payment period (PayType). Note that because YrIncome represents cash paid out from the annuity each year, it's a negative number.

PV([APR], [TotPmts], -[YrIncome], [FVal], [PayType])


Rate function example

This example uses the Rate function to calculate the interest rate of a loan given the total number of payments (TotPmts), the amount of the loan payment (Payment), the present value or principal of the loan (PVal), the future value of the loan (FVal), a number that indicates whether the payment is due at the beginning or end of the payment period (PayType), and an approximation of the expected interest rate (Guess).

(Rate([TotPmts], -[Payment], [PVal], [FVal], [PayType], [Guess]) * 12) * 100


Right function example

The following example returns four characters from the right side of the Subject field.

Subject field | Function returns
International Sales | ales
Marketing Strategy | tegy

Right([Subject], 4)


Rnd function example

The following example uses the Rnd function to display a field with a random integer value from 1 to 6.

Int((6 * Rnd) + 1)


ScrollBars, KeepScrollBarsVisible Properties Example

The following example uses the ScrollBars and the KeepScrollBarsVisible properties to add scroll bars to a page of a MultiPage and to a Frame. The user chooses an option button that, in turn, specifies a value for KeepScrollBarsVisible.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A MultiPage named MultiPage1.

  • A Frame named Frame1.

  • Four OptionButton controls named OptionButton1 through OptionButton4.
Sub Item_Open()
    Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
    Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")
    Set OptionButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton1")
    Set OptionButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton2")
    Set OptionButton3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton3")
    Set OptionButton4 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton4")

    MultiPage1.Pages(0).ScrollBars = 3    '3=fmScrollBarsBoth
    MultiPage1.Pages(0).KeepScrollBarsVisible = 0    '0=fmScrollBarsNone

    Frame1.ScrollBars = 3    '3=fmScrollBarsBoth
    Frame1.KeepScrollBarsVisible = 0    '0=fmScrollBarsNone

    OptionButton1.Caption = "No scroll bars"
    OptionButton1.Value = True
    OptionButton2.Caption = "Horizontal scroll bars"
    OptionButton3.Caption = "Vertical scroll bars"
    OptionButton4.Caption = "Both scroll bars"
End Sub

Sub OptionButton1_Click()
    Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
    Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")

    MultiPage1.Pages(0).KeepScrollBarsVisible = 0    '0=fmScrollBarsNone
    Frame1.KeepScrollBarsVisible = 0    '0=fmScrollBarsNonefmScrollBarsNone
End Sub

Sub OptionButton2_Click()
    Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
    Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")

    MultiPage1.Pages(0).KeepScrollBarsVisible = 1    '1=fmScrollBarsHorizontal
    Frame1.KeepScrollBarsVisible = 1    '1=fmScrollBarsHorizontal
End Sub

Sub OptionButton3_Click()
    Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
    Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")

    MultiPage1.Pages(0).KeepScrollBarsVisible = 2    '2=fmScrollBarsVertical
    Frame1.KeepScrollBarsVisible = 2    '2=fmScrollBarsVertical
End Sub

Sub OptionButton4_Click()
    Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
    Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")

    MultiPage1.Pages(0).KeepScrollBarsVisible = 3    '3=fmScrollBarsBoth
    Frame1.KeepScrollBarsVisible = 3    '3=fmScrollBarsBoth
End Sub


Second function example

The following example uses the Second function to return the second of the time of the Received field.

Second([Received])


Sgn function example

The following example returns the following values for the Angle field.

Angle field | Function returns
30 | 1
-45 | -1

Sgn([Angle])


Sin function example

The following example uses the Sin function to return the sine of the Angle field.

Sin([Angle])


SLN function example

This example uses the SLN function to return the straight-line depreciation of an asset for a single period given the asset's initial cost (InitCost), the salvage value at the end of the asset's useful life (SalvageVal), and the total life of the asset in years (LifeTime).

SLN([InitCost], [SalvageVal], [LifeTime])


Space function example

The following example uses the Space function to return 10 spaces between the values of the Sent and Received fields in a column.

[Sent] & Space(10) & [Received]


Sqr function example

This example returns the following values for the Angle field.

Angle field | Function returns
4 | 2
23 | 4.795831523313
0 | 0

Sqr([Angle])


StrComp function example

The following example compares the value of the File As field with the value of a combination of the First Name and Last Name fields.

StrComp([File As], [Last Name] & ", " & [First Name], 1)


Str function example

The following example uses the Str function to return a string representation of the Number field. When a number is converted to a string, a leading space is always reserved for its sign.

Number field | Function returns
459 | " 459"
-459.65 | "-459.65"
459.001 | " 459.001"

Str([Number])


String function example

The following examples use the String function to return repeating character strings of the length specified.

Function | Returns
String(5, "*") | *****
String(5, 42) | *****
String(10, "ABC") | AAAAAAAAAA


Style Property Example for ComboBox

The following example uses the Style property to change the effect of typing in the text area of a ComboBox. The user chooses a style by selecting an OptionButton control and then types into the ComboBox to select an item. When Style is StyleDropDownList, the user must choose an item from the drop-down list. When Style is StyleDropDownCombo, the user can type into the text area to specify an item in the drop-down list.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • Two OptionButton controls named OptionButton1 and OptionButton2.

  • A ComboBox named ComboBox1.
Sub OptionButton1_Click()
    Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
    ComboBox1.Style = 0        '0=fmStyleDropDownCombo
End Sub

Sub OptionButton2_Click()
    Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
    ComboBox1.Style = 2        '2=fmStyleDropDownList
End Sub

Sub Item_Open()
    Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
    Set OptionButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton1")
    Set OptionButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton2")

    For i = 1 To 10
        ComboBox1.AddItem "Choice " & i
    Next

    OptionButton1.Caption = "Select like ComboBox"
    OptionButton1.Value = True
    ComboBox1.Style = 0        '0=fmStyleDropDownCombo

    OptionButton2.Caption = "Select like ListBox"
End Sub


Style Property Example for MultiPage and TabStrip

The following example uses the Style property to specify the appearance of the tabs in MultiPage and TabStrip. This example also demonstrates using a Label. The user chooses a style by selecting an OptionButton.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A Label named Label1.

  • Three OptionButton controls named OptionButton1 through OptionButton3.

  • A MultiPage named MultiPage1.

  • A TabStrip named TabStrip1.

  • Any control inside the TabStrip.

  • Any control in each page of the MultiPage.
Sub OptionButton1_Click()
    Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
    Set TabStrip1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TabStrip1")
    MultiPage1.Style = 0        '0=fmTabStyleTabs
    TabStrip1.Style = 0        '0=fmTabStyleTabs
End Sub

Sub OptionButton2_Click()
    'Note that the page borders are invisible
    Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
    Set TabStrip1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TabStrip1")
    MultiPage1.Style = 1        '1=fmTabStyleButtons
    TabStrip1.Style = 1        '1=fmTabStyleButtons
End Sub

Sub OptionButton3_Click()
    'Note that the page borders are invisible and
    'the page body begins where the tabs normally appear.
    Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
    Set TabStrip1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TabStrip1")
    MultiPage1.Style = 2        '2=fmTabStyleNone
    TabStrip1.Style = 2        '2=fmTabStyleNone
End Sub

Sub Item_Open()
    Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label1")
    Set OptionButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton1")
    Set OptionButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton2")
    Set OptionButton3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton3")
    Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
    Set TabStrip1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TabStrip1")

    Label1.Caption = "Page/Tab Style"
    OptionButton1.Caption = "Tabs"
    OptionButton1.Value = True
    MultiPage1.Style = 0        '0=fmTabStyleTabs
    TabStrip1.Style = 0        '0=fmTabStyleTabs

    OptionButton2.Caption = "Buttons"
    OptionButton3.Caption = "No Tabs or Buttons"
End Sub


Switch function example

The following example uses the Switch function to return the name of a language that matches the name of the Business Address City field.

Business Address City field | Function returns
London | English
Paris | French

Switch([Business Address City] = "London",
"English", [Business Address City]= "Paris", "French")


SYD function example

By using the sum-of-years digits method, this example illustrates the use of the SYD function to return the depreciation of an asset for a specified period given the asset's initial cost (InitCost), the salvage value at the end of the asset's useful life (SalvageVal), and the total life of the asset in years (LifeTime). The period for which the depreciation is calculated is DepYear, also in years.

SYD([InitCost], [SalvageVal], [LifeTime], [DepYear])


TabFixedHeight, TabFixedWidth Properties Example

The following example uses the TabFixedHeight and TabFixedWidth properties to set the size of the tabs used in MultiPage and TabStrip. The user clicks the SpinButton controls to adjust the height and width of the tabs within the MultiPage and TabStrip.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A MultiPage named MultiPage1.

  • A TabStrip named TabStrip1.

  • A Label named Label1 for the width control.

  • A SpinButton named SpinButton1 for the width control that is bound to a custom number field named SpinButtonWidth.

  • A TextBox named TextBox1 for the width control.

  • A Label named Label2 for the height control.

  • A SpinButton named SpinButton2 for the height control that is bound to a custom number field named SpinButtonHeight.

  • A TextBox named TextBox2 for the height control.
Sub UpdateTabWidth()
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set SpinButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("SpinButton1")
    Set TabStrip1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TabStrip1")
    Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")

    TextBox1.Text = SpinButton1.Value
    TabStrip1.TabFixedWidth = SpinButton1.Value
    MultiPage1.TabFixedWidth = SpinButton1.Value
End Sub

Sub UpdateTabHeight()
    Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox2")
    Set SpinButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("SpinButton2")
    Set TabStrip1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TabStrip1")
    Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")

    TextBox2.Text = SpinButton2.Value
    TabStrip1.TabFixedHeight = SpinButton2.Value
    MultiPage1.TabFixedHeight = SpinButton2.Value
End Sub

Sub Item_Open()
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox2")
    Set SpinButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("SpinButton1")
    Set SpinButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("SpinButton2")
    Set TabStrip1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TabStrip1")
    Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
    Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label1")
    Set Label2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label2")

    MultiPage1.Style = 1        '1=fmTabStyleButtons

    Label1.Caption = "Tab Width"
    SpinButton1.Min = 0
    SpinButton1.Max = TabStrip1.Width / TabStrip1.Tabs.Count
    SpinButton1.Value = 0
    TextBox1.Locked = True

    UpdateTabWidth

    Label2.Caption = "Tab Height"
    SpinButton2.Min = 0
    SpinButton2.Max = TabStrip1.Height
    SpinButton2.Value = 0
    TextBox2.Locked = True

    UpdateTabHeight
End Sub

Sub Item_CustomPropertyChange(byval pname)
'msgbox pname
    If pname = "SpinButtonWidth" Then
        UpdateTabWidth
    ElseIf pname = "SpinButtonHeight" Then
        UpdateTabHeight
    End If
End Sub


TabIndex Property Example

The following example uses the TabIndex property to display and set the tab order for individual controls. The user can press TAB to reach the next control in the tab order and to display the TabIndex of that control. The user can also click on any control, except a TextBox or ScrollBar, to display its TabIndex. The user can change the TabIndex of a control by specifying a new index value in the TextBox and clicking CommandButton3. Changing the TabIndex for one control also updates the TabIndex for other controls in the Frame.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A Label named Label1.

  • A TextBox named TextBox1.

  • A Frame named Frame1.

  • A TextBox in the Frame named TextBox2.

  • Two CommandButton controls in the Frame named CommandButton1 and CommandButton2.

  • A ScrollBar in the Frame named ScrollBar1.

  • A CommandButton (not in the Frame) named CommandButton3.
Sub MoveToFront()
    Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")

    Temp = Frame1.ActiveControl.TabIndex
    For i = 0 To Temp - 1
        Frame1.Controls.Item(i).TabIndex = i + 1
    Next

    Frame1.ActiveControl.TabIndex = 0
    TextBox1.Text = Frame1.ActiveControl.TabIndex
End Sub

Sub CommandButton3_Click()
    Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")

    If IsNumeric(TextBox1.Text) Then
        Temp = CInt(TextBox1.Text)

        If Temp >= Frame1.Controls.Count Or Temp < 0 Then
            'Entry out of range; move control to front of tab order
            MoveToFront
        ElseIf Temp > Frame1.ActiveControl.TabIndex Then
            'Move entry down the list
            For i = Frame1.ActiveControl.TabIndex + 1 To Temp
                Frame1.Controls.Item(i).TabIndex = i - 1
            Next
            Frame1.ActiveControl.TabIndex = Temp
            TextBox1.Text = Frame1.ActiveControl.TabIndex
        Else
            'Move Entry up the list
            For i = Frame1.ActiveControl.TabIndex - 1 To Temp
                Frame1.Controls.Item(i).TabIndex = i + 1
            Next
            Frame1.ActiveControl.TabIndex = Temp
            TextBox1.Text = Frame1.ActiveControl.TabIndex
        End If
    Else
        'Text entry; move control to front of tab order
        MoveToFront
    End If
End Sub

Sub Item_Open()
    Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label1")
    Set CommandButton3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CommandButton3")

    Label1.Caption = "TabIndex"

    Frame1.Controls(0).SetFocus
    TextBox1.Text = Frame1.ActiveControl.TabIndex

    Frame1.Cycle = 2        '2=fmCycleCurrentForm

    CommandButton3.Caption = "Set TabIndex"
    CommandButton3.TakeFocusOnClick = False
End Sub

Sub CommandButton1_Click()
    Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")

    TextBox1.Text = Frame1.ActiveControl.TabIndex
End Sub

Sub CommandButton2_Click()
    Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")

    TextBox1.Text = Frame1.ActiveControl.TabIndex
End Sub


TabStop Property Example

The following example uses the TabStop property to control whether a user can press TAB to move the focus to a particular control. The user presses TAB to move the focus among the controls on the form, and then clicks the ToggleButton to change TabStop for CommandButton1. When TabStop is False, CommandButton1 will not receive the focus by using TAB.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A CommandButton named CommandButton1.

  • A ToggleButton named ToggleButton1.

  • One or two other controls, such as an OptionButton or ListBox.
Sub CommandButton1_Click()
    MsgBox "Clicked CommandButton1."
End Sub

Sub ToggleButton1_Click()
    Dim CommandButton1
    Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton1")
    Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CommandButton1")

    If ToggleButton1 = True Then
        CommandButton1.TabStop = True
        ToggleButton1.Caption = "TabStop On"
    Else
        CommandButton1.TabStop = False
        ToggleButton1.Caption = "TabStop Off"
    End If
End Sub

Sub Item_Open()
    Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton1")
    Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CommandButton1")

    CommandButton1.Caption = "Show Message"

    ToggleButton1.Caption = "TabStop On"
    ToggleButton1.Value = True
    ToggleButton1.Width = 90
End Sub


Tag Property Example

The following example uses the Tag property to store additional information about each control on the UserForm. The user clicks a control and then clicks the CommandButton. The contents of Tag for the appropriate control are returned in the TextBox.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A TextBox named TextBox1.

  • A CommandButton named CommandButton1.

  • A ScrollBar named ScrollBar1.

  • A ComboBox named ComboBox1.

  • A MultiPage named MultiPage1.
Sub CommandButton1_Click()
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set MultiPage1= Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")

    TextBox1.Text = Item.GetInspector.ModifiedFormPages("P.2").ActiveControl.Tag
End Sub

Sub Item_Open()
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set CommandButton1= Item.GetInspector.ModifiedFormPages("P.2").Controls("CommandButton1")
    Set ComboBox1= Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
    Set ScrollBar1= Item.GetInspector.ModifiedFormPages("P.2").Controls("ScrollBar1")
    Set MultiPage1= Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")

    TextBox1.Locked = True
    TextBox1.Tag = "Display area for Tag properties."
    TextBox1.AutoSize = True

    CommandButton1.Caption = "Show Tag of Current Control."
    CommandButton1.AutoSize = True
    CommandButton1.WordWrap = True
    CommandButton1.TakeFocusOnClick = False
    CommandButton1.Tag = "Shows tag of control that has the focus."

    ComboBox1.Style = fmStyleDropDownList
    ComboBox1.Tag = "ComboBox Style is that of a ListBox."

    ScrollBar1.Max = 100
    ScrollBar1.Min = -273
    ScrollBar1.Tag = "Max = " & ScrollBar1.Max & " , Min = " & ScrollBar1.Min

    MultiPage1.Pages.Add
    MultiPage1.Pages.Add
    MultiPage1.Tag = "This MultiPage has " & MultiPage1.Pages.Count & " pages."
End Sub


TakeFocusOnClick Property Example

The following example uses the TakeFocusOnClick property to control whether a CommandButton receives the focus when the user clicks on it. The user clicks a control other than CommandButton1 and then clicks CommandButton1. If TakeFocusOnClick is True, CommandButton1 receives the focus after it is clicked. The user can change the value of TakeFocusOnClick by clicking the ToggleButton.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A CommandButton named CommandButton1.

  • A ToggleButton named ToggleButton1.

  • One or two other controls, such as an OptionButton or ListBox.
Sub CommandButton1_Click()
    MsgBox "Watch CommandButton1 to see if it takes the focus."
End Sub

Sub ToggleButton1_Click()
    Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton1")
    Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CommandButton1")

    If ToggleButton1 = True Then
        CommandButton1.TakeFocusOnClick = True
        ToggleButton1.Caption = "TakeFocusOnClick On"
    Else
        CommandButton1.TakeFocusOnClick = False
        ToggleButton1.Caption = "TakeFocusOnClick Off"
    End If
End Sub

Sub Item_Open()
    Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton1")
    Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CommandButton1")

    CommandButton1.Caption = "Show Message"

    ToggleButton1.Caption = "TakeFocusOnClick On"
    ToggleButton1.Value = True
    ToggleButton1.Width = 90
End Sub


Tan function example

The following example uses the Tan function to return the tangent of the numeric field Angle.

Tan([Angle])


TextColumn Property Example

The following example uses the TextColumn property to identify the column of data in a ListBox that supplies data for its Text property. This example sets the third column of the ListBox as the text column. As you select an entry from the ListBox, the value from the TextColumn will be displayed in the TextBox.

This example also demonstrates how to load a multicolumn ListBox using the AddItem method and the List property.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A ListBox named ListBox1.

  • A TextBox named TextBox1.
Dim ListBox1
Dim TextBox1

Sub Item_Open()
    Set ListBox1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("ListBox1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("TextBox1")

    ListBox1.ColumnCount = 3

    ListBox1.AddItem "Row 1, Col 1"
    ListBox1.List(0, 1) = "Row 1, Col 2"
    ListBox1.List(0, 2) = "Row 1, Col 3"

    ListBox1.AddItem "Row 2, Col 1"
    ListBox1.List(1, 1) = "Row 2, Col 2"
    ListBox1.List(1, 2) = "Row 2, Col 3"

    ListBox1.AddItem "Row 3, Col 1"
    ListBox1.List(2, 1) = "Row 3, Col 2"
    ListBox1.List(2, 2) = "Row 3, Col 3"

    ListBox1.TextColumn = 3

End Sub

Sub ListBox1_Click()
    TextBox1.Text = ListBox1.Text
End Sub


Time function example

The following example uses the Time function to return the current system time.

Time( )


Timer function example

The following example uses the Timer function to return the seconds elapsed since midnight.

Timer( )


TimeSerial function example

The following example uses the TimeSerial function to return a time for the values specified in the Hour, Minute, and Second custom fields.

TimeSerial([Hour], [Minute], [Second])


TimeValue function example

The following example uses the TimeValue function to return a string entered in the Other field as a time.

TimeValue([Other])


TopIndex Property Example

The following example identifies the top item displayed in a ListBox and the item that has the focus within the ListBox. This example uses the TopIndex property to identify the item displayed at the top of the ListBox and the ListIndex property to identify the item that has the focus. The user selects an item in the ListBox. The displayed values of TopIndex and ListIndex are updated when the user selects an item or when the user clicks the CommandButton.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A Label named Label1.

  • A TextBox named TextBox1.

  • A Label named Label2.

  • A TextBox named TextBox2.

  • A CommandButton named CommandButton1.

  • A ListBox named ListBox1 that is bound to the Subject field.
Sub CommandButton1_Click()
    Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox2")

    ListBox1.TopIndex = ListBox1.ListIndex
    TextBox1.Text = ListBox1.TopIndex
    TextBox2.Text = ListBox1.ListIndex
End Sub

Sub Item_PropertyChange(byval pname)
    if pname = "Subject" then
        Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
        Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox2")
        Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox1")

        TextBox1.Text = ListBox1.TopIndex
        TextBox2.Text = ListBox1.ListIndex
    end if
End Sub

Sub Item_Open()
    Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox1")
    Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CommandButton1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox2")
    Set Label1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label1")
    Set Label2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Label2")

    For i = 0 To 24
        ListBox1.AddItem "Choice " & (i + 1)
    Next
    ListBox1.Height = 66
    CommandButton1.Caption = "Move to top of list"
    CommandButton1.AutoSize = True
    CommandButton1.TakeFocusOnClick = False

    Label1.Caption = "Index of top item"
    TextBox1.Text = ListBox1.TopIndex

    Label2.Caption = "Index of current item"
    Label2.AutoSize = True
    Label2.WordWrap = False
    TextBox2.Text = ListBox1.ListIndex
End Sub


 TripleState Property Example

TripleState Property Example

The following example uses the TripleState property to allow Null as a legal value of a CheckBox and a ToggleButton. The user controls the value of TripleState through ToggleButton2. The user can set the value of a CheckBox or ToggleButton based on the value of TripleState. However, when a control is set to Null, no event is fired.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A CheckBox named CheckBox1.

  • A ToggleButton named ToggleButton1.

  • A ToggleButton named ToggleButton2.
Sub Item_Open()
    Set CheckBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CheckBox1")
    Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton1")
    Set ToggleButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton2")

    CheckBox1.Caption = "Value is True"
    CheckBox1.Value = True
    CheckBox1.TripleState = False

    ToggleButton1.Caption = "Value is True"
    ToggleButton1.Value = True
    ToggleButton1.TripleState = False

    ToggleButton2.Value = False
    ToggleButton2.Caption = "Triple State Off"
End Sub

Sub ToggleButton2_Click()
    Set CheckBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CheckBox1")
    Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton1")
    Set ToggleButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton2")

    If ToggleButton2.Value = True Then
        ToggleButton2.Caption = "Triple State On"
        CheckBox1.TripleState = True
        ToggleButton1.TripleState = True
    Else
        ToggleButton2.Caption = "Triple State Off"
        CheckBox1.TripleState = False
        ToggleButton1.TripleState = False
    End If
End Sub

Sub CheckBox1_Click()
    Set CheckBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CheckBox1")
    If IsNull(CheckBox1.Value) Then
        CheckBox1.Caption = "Value is Null"
    ElseIf CheckBox1.Value = False Then
        CheckBox1.Caption = "Value is False"
    ElseIf CheckBox1.Value = True Then
        CheckBox1.Caption = "Value is True"
    End If
End Sub

Sub ToggleButton1_Click()
    Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton1")
    If IsNull(ToggleButton1.Value) Then
        ToggleButton1.Caption = "Value is Null"
    ElseIf ToggleButton1.Value = False Then
        ToggleButton1.Caption = "Value is False"
    ElseIf ToggleButton1.Value = True Then
        ToggleButton1.Caption = "Value is True"
    End If
End Sub


UCase function example

The following example returns uppercase values of the Subject field.

Subject field | Function returns
International Sales | INTERNATIONAL SALES
Marketing Strategy | MARKETING STRATEGY

UCase([Subject])


Val function example

The following example uses the Val function to return the numbers contained in the field String.

String field | Function returns
"2457" | 2457
"2 45 7" | 2457
"24 and 57" | 24

Val([String])


Value Property Example

The following example demonstrates the values that the different types of controls can have by displaying the Value property of a selected control. The user chooses a control by pressing TAB or by clicking on the control. Depending on the type of control, the user can also specify a value for the control by typing in the text area of the control, by clicking one or more times on the control, or by selecting an item, page, or tab within the control. The user can display the value of the selected control by clicking the appropriately labeled CommandButton.

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • A CommandButton named CommandButton1.

  • A TextBox named TextBox1.

  • A CheckBox named CheckBox1.

  • A ComboBox named ComboBox1.

  • A CommandButton named CommandButton2.

  • A ListBox named ListBox1.

  • A MultiPage named MultiPage1.

  • Two OptionButton controls named OptionButton1 and OptionButton2.

  • A ScrollBar named ScrollBar1.

  • A SpinButton named SpinButton1.

  • A TabStrip named TabStrip1.

  • A TextBox named TextBox2.

  • A ToggleButton named ToggleButton1.
Sub CommandButton1_Click()
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set Form = Item.GetInspector.ModifiedFormPages("P.2")
     TextBox1.Text = "Value of " & Form.ActiveControl.Name & " is " &     Form.ActiveControl.Value
End Sub

Sub Item_Open()
    Set CommandButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CommandButton1")
    Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1")
    Set ComboBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ComboBox1")
    Set ListBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ListBox1")
    Set CheckBox1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("CheckBox1")
    Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("ToggleButton1")
    Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox2")

    CommandButton1.Caption = "Get value of current control"
    CommandButton1.AutoSize = True
    CommandButton1.TakeFocusOnClick = False
    CommandButton1.TabStop = False

    TextBox1.AutoSize = True

    For i = 0 To 10
        ComboBox1.AddItem "Choice " & (i + 1)
        ListBox1.AddItem "Selection " & (100 - i)
    Next

    CheckBox1.TripleState = True
    ToggleButton1.TripleState = True

    TextBox2.Text = "Enter text here."
End Sub


Weekday function example

The following example uses the Weekday function to obtain the day of the week from the Received field.

Weekday([Received])


Year function example

The following example uses the Year function to return the year of the Received field.

Year([Received])


ZOrder Method Example

The following example sets the z-order of a TextBox, so the user can display the entire TextBox (by bringing it to the front of the z-order) or can place the TextBox behind other controls (by sending it to the back of the z-order).

To use this example, copy this sample code to the Script Editor of a form. To run the code you need to open the form so the Open event will activate. Make sure that the form contains:

  • Three TextBox controls named TextBox1 through TextBox3.

  • A ToggleButton named ToggleButton1.
Dim ToggleButton1
Dim TextBox1
Dim TextBox2
Dim TextBox3

Sub Item_Open()
Set TextBox1 = Item.GetInspector.ModifiedFormPages("P.2").TextBox1
Set TextBox2 = Item.GetInspector.ModifiedFormPages("P.2").TextBox2
Set TextBox3 = Item.GetInspector.ModifiedFormPages("P.2").TextBox3
Set ToggleButton1 = Item.GetInspector.ModifiedFormPages("P.2").ToggleButton1

'Set up text boxes to show z-order in the form
TextBox1.Text = "TextBox 1"
TextBox2.Text = "TextBox 2"
TextBox3.Text = "TextBox 3"

TextBox1.Height = 40
TextBox2.Height = 40
TextBox3.Height = 40

TextBox1.Width = 60
TextBox2.Width = 60
TextBox3.Width = 60

TextBox1.Left = 10
TextBox1.Top = 10

TextBox2.Left = 25      'Overlap TextBox2 on TextBox1
TextBox2.Top = 25

TextBox3.Left = 40      'Overlap TextBox3 on TextBox2, TextBox1
TextBox3.Top = 40

ToggleButton1.Value = False
ToggleButton1.Caption = "Bring TextBox2 to Front"
ToggleButton1.Left = 10
ToggleButton1.Top = 90
ToggleButton1.Width = 50
ToggleButton1.Height = 50

End Sub

Sub ToggleButton1_Click()
If ToggleButton1.Value = True Then
  TextBox2.ZOrder (fmTop)          'Place TextBox2 on Top of z-order

  'Update ToggleButton caption to identify next state
  ToggleButton1.Caption = "Send TextBox2 to back"
Else
    TextBox2.ZOrder (1)              'Place TextBox2 on Bottom of z-order

    'Update ToggleButton caption to identify next state
    ToggleButton1.Caption = "Bring TextBox2 to front"
End If
End Sub


 Abs function

Abs function

Returns a value of the same type that is passed to it specifying the absolute value of a number.

Syntax

Abs(number)

The required number argument can be any valid numeric expression. If number contains Null, Null is returned.

Remarks

The absolute value of a number is its unsigned magnitude. For example, ABS(-1) and ABS(1) both return 1.


 Asc function

Asc function

Returns an Integer representing the character code corresponding to the first letter in a string.

Syntax

Asc(string)

The required string argument is any valid string expression. If the string contains no characters, a run-time error occurs.

Remarks

The range for returns is 0-255 on non-DBCS systems, but -32768-32767 on DBCS systems.

Note The AscW function returns the character code native to the system (ANSI for Windows 95, Unicode for Windows NT).


 Atn function

Atn function

Returns a Double specifying the arctangent of a number.

Syntax

Atn(number)

The required number argument is a Double or any valid numeric expression.

Remarks

The Atn function takes the ratio of two sides of a right triangle (number) and returns the corresponding angle in radians. The ratio is the length of the side opposite the angle divided by the length of the side adjacent to the angle.

The range of the result is - pi/2 to pi/2 radians.

To convert degrees to radians, multiply degrees by pi/180. To convert radians to degrees, multiply radians by 180/pi.

Note Atn is the inverse trigonometric function of Tan, which takes an angle as its argument and returns the ratio of two sides of a right triangle. Do not confuse Atn with the cotangent, which is the simple inverse of a tangent (1/tangent).


 Choose function

Choose function

Selects and returns a value from a list of arguments.

Syntax

Choose(index, choice-1[, choice-2, ... [, choice-n]])

The Choose function syntax has these parts:

Part | Description
index | Required. Numeric expression or field that results in a value between 1 and the number of available choices.
choice | Required. Variant expression containing one of the possible choices.

Remarks

Choose returns a value from the list of choices based on the value of index. If index is 1, Choose returns the first choice in the list; if index is 2, it returns the second choice, and so on.

You can use Choose to look up a value in a list of possibilities. For example, if index evaluates to 3 and choice-1 = "one", choice-2 = "two", and choice-3 = "three", Choose returns "three".

Choose evaluates every choice in the list, even though it returns only one. For this reason, you should watch for undesirable side effects. For example, if the evaluation of any expression results in a division by zero error, an error occurs.

The Choose function returns a Null if index is less than 1 or greater than the number of choices listed.

If index is not a whole number, it is rounded down to the next whole number before being evaluated.


 Chr function

Chr function

Returns a String containing the character associated with the specified character code.

Syntax

Chr(charcode)

The required charcode argument is a Long that identifies a character.

Remarks

Numbers from 0 to 31 are the same as standard, nonprintable ASCII codes. For example, Chr(10) returns a linefeed character. The normal range for charcode is 0 – 255. However, on DBCS systems, the actual range for charcode is – 32768 through 65536.

Note The ChrW function returns a string containing the character in the format native to the operating system (ANSI for Windows 95, Unicode for Windows NT).


 Cos function

Cos function

Returns a Double specifying the cosine of an angle.

Syntax

Cos(number)

The required number argument is a Double or any valid numeric expression that expresses an angle in radians.

Remarks

The Cos function takes an angle and returns the ratio of two sides of a right triangle. The ratio is the length of the side adjacent to the angle divided by the length of the hypotenuse.

The result lies in the range -1 to 1.

To convert degrees to radians, multiply degrees by pi/180. To convert radians to degrees, multiply radians by 180/pi.


Date function

Returns a Variant (Date) containing the current system date.

Syntax

Date( )


 DateAdd function

DateAdd function

Returns a Variant (Date) containing a date to which a specified time interval has been added.

Syntax

DateAdd(interval, number, date)

The DateAdd function syntax has these named arguments:

Part | Description
interval | Required. String expression that is the interval of time you want to add.

number | Required. Numeric expression that is the number of intervals you want to add. It can be positive (to get dates in the future) or negative (to get dates in the past).
date | Required. Variant (Date) or literal representing date to which the interval is added.

Settings

The interval argument has these settings:

Setting | Description
yyyy | Year
q | Quarter
m | Month
y | Day of year
d | Day
w | Weekday
ww | Week
h | Hour
n | Minute
s | Second

Remarks

You can use the DateAdd function to add or subtract a specified time interval from a date. For example, you can use DateAdd to calculate a date 30 days from today or a time 45 minutes from now.

To add days to date, you can use Day of Year ("y"), Day ("d"), or Weekday ("w").

The DateAdd function won't return an invalid date. The following example adds one month to January 31:

DateAdd("m", 1, "31-Jan-95")

In this case, DateAdd returns 28-Feb-95, not 31-Feb-95. If date is 31-Jan-96, it returns 29-Feb-96 because 1996 is a leap year.

If the calculated date would precede the year 100 (that is, you subtract more years than are in date), an error occurs.

If number isn't a Long value, it is rounded to the nearest whole number before being evaluated.


 DateDiff function

DateDiff function

Returns a Variant (Long) specifying the number of time intervals between two specified dates.

Syntax

DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])

The DateDiff function syntax has these named arguments:

Part | Description
interval | Required. String expression that is the interval of time you use to calculate the difference between date1 and date2.
date1, date2 | Required; Variant (Date). Two dates you want to use in the calculation.
firstdayofweek | Optional. Specifies the first day of the week. If not specified, Sunday is assumed.
firstweekofyear | Optional. Specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs.

Settings

The interval argument has these settings:

Setting | Description
yyyy | Year
q | Quarter
m | Month
y | Day of year
d | Day
w | Weekday
ww | Week
h | Hour
n | Minute
s | Second

The firstdayofweek argument has these settings:

Value | Description
0 | Use the NLS API setting.
1 | Sunday (default)
2 | Monday
3 | Tuesday
4 | Wednesday
5 | Thursday
6 | Friday
7 | Saturday

The firstweekofyear argument has these settings:

Value | Description
0 | Use the NLS API setting.
1 | Start with week in which January 1 occurs (default).
2 | Start with the first week that has at least four days in the new year.
3 | Start with first full week of the year.

Remarks

You can use the DateDiff function to determine how many specified time intervals exist between two dates. For example, you might use DateDiff to calculate the number of days between two dates, or the number of weeks between today and the end of the year.

To calculate the number of days between date1 and date2, you can use either Day of year ("y") or Day ("d"). When interval is Weekday ("w"), DateDiff returns the number of weeks between the two dates. If date1 falls on a Monday, DateDiff counts the number of Mondays until date2. It counts date2 but not date1. If interval is Week ("ww"), however, the DateDiff function returns the number of calendar weeks between the two dates. It counts the number of Sundays between date1 and date2. DateDiff counts date2 if it falls on a Sunday; but it doesn't count date1, even if it does fall on a Sunday.

If date1 refers to a later point in time than date2, the DateDiff function returns a negative number.

The firstdayofweek argument affects calculations that use the "w" and "ww" interval symbols.

If date is a date literal, the specified year becomes a permanent part of that date. However, if date is enclosed in double quotation marks (" "), and you omit the year, the current year is used each time the date expression is evaluated. This makes it possible to write formulas that can be used in different years.

When comparing December 31 to January 1 of the immediately succeeding year, DateDiff for Year ("yyyy") returns 1 even though only a day has elapsed.


 DatePart function

DatePart function

Returns a Variant (Integer) containing the specified part of a given date.

Syntax

DatePart(interval, date[,firstdayofweek[, firstweekofyear]])

The DatePart function syntax has these named arguments:

Part | Description
interval | Required. String expression that is the interval of time you want to return.
date | Required. Variant (Date) value that you want to evaluate.
firstdayofweek | Optional. Specifies the first day of the week. If not specified, Sunday is assumed.
firstweekofyear | Optional. Specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs.

Settings

The interval argument has these settings:

Setting | Description
yyyy | Year
q | Quarter
m | Month
y | Day of year
d | Day
w | Weekday
ww | Week
h | Hour
n | Minute
s | Second

The firstdayofweek argument has these settings:

Value | Description
0 | Use the NLS API setting.
1 | Sunday (default)
2 | Monday
3 | Tuesday
4 | Wednesday
5 | Thursday
6 | Friday
7 | Saturday

The firstweekofyear argument has these settings:

Value | Description
0 | Use the NLS API setting.
1 | Start with week in which January 1 occurs (default).
2 | Start with the first week that has at least four days in the new year.
3 | Start with first full week of the year.

Remarks

You can use the DatePart function to evaluate a date and return a specific interval of time For example, you might use DatePart to calculate the day of the week or the current hour.

The firstdayofweek argument affects calculations that use the "w" and "ww" interval symbols.

If date is a date literal, the specified year becomes a permanent part of that date. However, if date is enclosed in double quotation marks (" "), and you omit the year, the current year is used each time the date expression is evaluated. This makes it possible to write formulas that can be used in different years.


 DateSerial function

DateSerial function

Returns a Variant (Date) for a specified year, month, and day.

Syntax

DateSerial(year, month, day)

The DateSerial function syntax has these named arguments:

Part | Description
year | Required; Integer. Number between 100 and 9999, inclusive, or a numeric expression.
month | Required; Integer. Any numeric expression.
day | Required; Integer. Any numeric expression.

Remarks

To specify a date, such as December 31, 1991, the range of numbers for each DateSerial argument should be in the accepted range for the unit; that is, 1 – 31 for days and 1 – 12 for months. However, you can also specify relative dates for each argument using any numeric expression that represents some number of days, months, or years before or after a certain date.

The following example uses numeric expressions instead of absolute date numbers. Here the DateSerial function returns a date that is the day before the first day (1 - 1), two months before August (8 - 2), 10 years before 1990 (1990 - 10); in other words, May 31, 1980.

DateSerial(1990 - 10, 8 - 2, 1 - 1)

For the year argument, values between 0 and 99, inclusive, are interpreted as the years 1900 – 1999. For all other year arguments, use a four-digit year (for example, 1800).

When any argument exceeds the accepted range for that argument, it increments to the next larger unit as appropriate. For example, if you specify 35 days, it is evaluated as one month and some number of days, depending on where in the year it is applied. If any single argument is outside the range -32,768 to 32,767, an error occurs. If the date specified by the three arguments falls outside the acceptable range of dates, an error occurs.


 DateValue function

DateValue function

Returns a Variant (Date).

Syntax

DateValue(date)

The required date argument is normally a string expression representing a date from January 1, 100 through December 31, 9999. However, date can also be any expression that can represent a date, a time, or both a date and time, in that range.

Remarks

If date is a string that includes only numbers separated by valid date separators, DateValue recognizes the order for month, day, and year according to the Short Date format you specified for your system. DateValue also recognizes unambiguous dates that contain month names, either in long or abbreviated form. For example, in addition to recognizing 12/30/1991 and 12/30/91, DateValue also recognizes December 30, 1991 and Dec 30, 1991.

If the year part of date is omitted, DateValue uses the current year from your computer's system date.

If the date argument includes time information, DateValue doesn't return it. However, if date includes invalid time information (such as "89:98"), an error occurs.

In Outlook, you can use a Date/Time field to have dates entered as descriptions converted to a standard Date format.


 Day function

Day function

Returns a Variant (Integer) specifying a whole number between 1 and 31, inclusive, representing the day of the month.

Syntax

Day(date)

The required date argument is any Variant, numeric expression, string expression, or any combination, that can represent a date. If date contains Null, Null is returned.


 DDB function

DDB function

Returns a Double specifying the depreciation of an asset for a specific time period using the double-declining balance method or some other method you specify.

Syntax

DDB(cost, salvage, life, period[, factor])

The DDB function has these named arguments:

Part | Description
cost | Required. Double specifying initial cost of the asset.
salvage | Required. Double specifying value of the asset at the end of its useful life.
life | Required. Double specifying length of useful life of the asset.
period | Required. Double specifying period for which asset depreciation is calculated.
factor | Optional. Variant specifying rate at which the balance declines. If omitted, 2 (double-declining method) is assumed.

Remarks

The double-declining balance method computes depreciation at an accelerated rate. Depreciation is highest in the first period and decreases in successive periods.

The arguments life and period must be expressed in the same units. For example, if life is given in months, period must also be given in months. All arguments must be positive numbers.

The DDB function uses the following formula to calculate depreciation for a given period:

Depreciation over period = ((cost – salvage) * factor) / life


 Different formats for different numeric values (Format function)

Different formats for different numeric values (Format function)

A user-defined format expression for numbers can have from one to four sections separated by semicolons. (If the format argument contains one of the named numeric formats, only one section is allowed.)

If you use | The result is
One section only | The format expression applies to all values.
Two sections | The first section applies to positive values and zeros, the second to negative values.
Three sections | The first section applies to positive values, the second to negative values, and the third to zeros.
Four sections | The first section applies to positive values, the second to negative values, the third to zeros, and the fourth to Null values.

The following example has two sections: the first defines the format for positive values and zeros; the second section defines the format for negative values.

"$#,##0;($#,##0)"

If you include semicolons with nothing between them, the missing section is printed using the format of the positive value. For example, the following format displays positive and negative values using the format in the first section and displays "Zero" if the value is zero.

"$#,##0;;\Z\e\r\o"


 Different formats for different string values (Format function)

Different formats for different string values (Format function)

A format expression for strings can have one section, or two sections separated by a semicolon.

If you use | The result is
One section only | The format applies to all string data.
Two sections | The first section applies to string data, the second to Null values and zero-length strings ("").


 Exp function

Exp function

Returns a Double specifying e (the base of natural logarithms) raised to a power.

Syntax

Exp(number)

The required number argument is a Double or any valid numeric expression.

Remarks

If the value of number exceeds 709.782712893, an error occurs. The constant e is approximately 2.718282.

Note The Exp function complements the action of the Log function and is sometimes referred to as the antilogarithm.


 Int, Fix functions

Int, Fix functions

Returns a value of the type passed to it containing the integer portion of a number.

Syntax

Int(number)

Fix(number)

The required number argument is a Double or any valid numeric expression. If number contains Null, Null is returned.

Remarks

Both Int and Fix remove the fractional part of number and return the resulting integer value.

The difference between Int and Fix is that if number is negative, Int returns the first negative integer less than or equal to number, whereas Fix returns the first negative integer greater than or equal to number. For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) is equivalent to:

Sgn(number) * Int(Abs(number))


 Format function

Format function

Returns a Variant (String) containing an expression formatted according to instructions contained in a format expression.

Syntax

Format(expression[, format[, firstdayofweek[, firstweekofyear]]])

The Format function syntax has these parts:

Part | Description
expression | Required. Any valid expression.
format | Optional. A valid named or user-defined format expression.
firstdayofweek | Optional. Specifies the first day of the week.
firstweekofyear | Optional. Specifies the first week of the year.

Settings

The firstdayofweek argument has these settings:

Value | Description
0 | Use NLS API setting.
1 | Sunday (default)
2 | Monday
3 | Tuesday
4 | Wednesday
5 | Thursday
6 | Friday
7 | Saturday

The firstweekofyear argument has these settings:

Value | Description
0 | Use NLS API setting.
1 | Start with week in which January 1 occurs (default).
2 | Start with the first week that has at least four days in the year.
3 | Start with the first full week of the year.

Remarks

To Format | Do This
Numbers | Use predefined named numeric formats or create user-defined numeric formats.
Dates and times | Use predefined named date/time formats or create user-defined date/time formats.
Date and time serial numbers | Use date and time formats or numeric formats.
Strings | Create your own user-defined string formats.

If you try to format a number without specifying format, Format provides functionality similar to the Str function, although it is internationally aware. However, positive numbers formatted as strings using Format don't include a leading space reserved for the sign of the value; those converted using Str retain the leading space.


 FV function

FV function

Returns a Double specifying the future value of an annuity based on periodic, constant payments and a constant interest rate.

Syntax

FV(rate, nper, pmt[, pv[, type]])

The FV function has these named arguments:

Part | Description
rate | Required. Double specifying interest rate per period. For example, if you get a car loan at an annual percentage rate (APR) of 10 percent and make monthly payments, the rate per period is 0.1/12, or 0.0083.
nper | Required. Integer specifying total number of payment periods in the annuity. For example, if you make monthly payments on a four-year car loan, your loan has a total of 4 * 12 (or 48) payment periods.
pmt | Required. Double specifying payment to be made each period. Payments usually contain principal and interest that doesn't change over the life of the annuity.
pv | Optional. Variant specifying present value (or lump sum) of a series of future payments. For example, when you borrow money to buy a car, the loan amount is the present value to the lender of the monthly car payments you will make. If omitted, 0 is assumed.
type | Optional. Variant specifying when payments are due. Use 0 if payments are due at the end of the payment period, or use 1 if payments are due at the beginning of the period. If omitted, 0 is assumed.

Remarks

An annuity is a series of constant cash payments made over a period of time. An annuity can be a loan (such as a home mortgage) or an investment (such as a monthly savings plan).

The arguments rate and nper must be calculated using payment periods expressed in the same units. For example, if rate is calculated using months, nper must also be calculated using months.

For all arguments, cash paid out (such as deposits to savings) is represented by negative numbers; cash received (such as dividend checks) is represented by positive numbers.


 Hex function

Hex function

Returns a String representing the hexadecimal value of a number.

Syntax

Hex(number)

The required number argument is any valid numeric expression or string expression.

Remarks

If number is not already a whole number, it is rounded to the nearest whole number before being evaluated.

If number is | Hex returns
Null | Null.
Empty | Zero (0).
Any other number | Up to eight hexadecimal characters.

You can represent hexadecimal numbers directly by preceding numbers in the proper range with &H. For example, &H10 represents decimal 16 in hexadecimal notation.


 Hour function

Hour function

Returns a Variant (Integer) specifying a whole number between 0 and 23, inclusive, representing the hour of the day.

Syntax

Hour(time)

The required time argument is any Variant, numeric expression, string expression, or any combination, that can represent a time. If time contains Null, Null is returned.


 IIf function

IIf function

Returns one of two parts, depending on the evaluation of an expression.

Syntax

IIf(expr, truepart, falsepart)

The IIf function syntax has these named arguments:

Part | Description
expr | Required. Expression you want to evaluate.
truepart | Required. Value or expression returned if expr is True.
falsepart | Required. Value or expression returned if expr is False.

Remarks

IIf always evaluates both truepart and falsepart, even though it returns only one of them. Because of this, you should watch for undesirable side effects. For example, if evaluating falsepart results in a division by zero error, an error occurs even if expr is True.


 InStr function

InStr function

Returns a Variant (Long) specifying the position of the first occurrence of one string within another.

Syntax

InStr([start, ]string1, string2[, compare])

The InStr function syntax has these named arguments:

Part | Description
start | Optional. Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. If start contains Null, an error occurs. The start argument is required if compare is specified.
string1 | Required. String expression being searched.
string2 | Required. String expression sought.
compare | Optional. Specifies the type of string comparison. The compare argument can be omitted, or it can be 0 or 1. Specify 0 (default) to perform a binary comparison. Specify 1 to perform a textual, case-insensitive comparison. If compare is Null, an error occurs. If compare is omitted, the comparison method is binary.

Return Values

If | InStr returns
string1 is zero-length | 0
string1 is Null | Null
string2 is zero-length | start
string2 is Null | Null
string2 is not found | 0
string2 is found within string1 | Position at which match is found
start > string2 | 0


 IPmt function

IPmt function

Returns a Double specifying the interest payment for a given period of an annuity based on periodic, constant payments and a constant interest rate.

Syntax

IPmt(rate, per, nper, pv[, fv[, type]])

The IPmt function has these named arguments:

Part | Description
rate | Required. Double specifying interest rate per period. For example, if you get a car loan at an annual percentage rate (APR) of 10 percent and make monthly payments, the rate per period is 0.1/12, or 0.0083.
per | Required. Double specifying payment period in the range 1 through nper.
nper | Required. Double specifying total number of payment periods in the annuity. For example, if you make monthly payments on a four-year car loan, your loan has a total of 4 * 12 (or 48) payment periods.
pv | Required. Double specifying present value, or value today, of a series of future payments or receipts. For example, when you borrow money to buy a car, the loan amount is the present value to the lender of the monthly car payments you will make.
fv | Optional. Variant specifying future value or cash balance you want after you've made the final payment. For example, the future value of a loan is $0 because that's its value after the final payment. However, if you want to save $50,000 over 18 years for your child's education , then $50,000 is the future value. If omitted, 0 is assumed.
type | Optional. Variant specifying when payments are due. Use 0 if payments are due at the end of the payment period, or use 1 if payments are due at the beginning of the period. If omitted, 0 is assumed.

Remarks

An annuity is a series of constant cash payments made over a period of time. An annuity can be a loan (such as a home mortgage) or an investment (such as a monthly savings plan).

The arguments rate and nper must be calculated using payment periods expressed in the same units. For example, if rate is calculated using months, nper must also be calculated using months.

For all arguments, cash paid out (such as deposits to savings) is represented by negative numbers; cash received (such as dividend checks) is represented by positive numbers.


 IsDate function

IsDate function

Returns a Boolean value indicating whether an expression can be converted to a date.

Syntax

IsDate(expression)

The required expression argument is a Variant containing a date expression or string expression recognizable as a date or time.

Remarks

IsDate returns True if the expression is a date or can be converted to a valid date; otherwise, it returns False. In Microsoft Windows, the range of valid dates is January 1, 100 A.D. through December 31, 9999 A.D.; the ranges vary among operating systems.

Unlike a Date/Time field in Outlook, text descriptions such as "next Thursday" are not recognized as valid expressions for the IsDate function.


 LCase function

LCase function

Returns a String that has been converted to lowercase.

Syntax

LCase(string)

The required string argument is any valid string expression. If string contains Null, Null is returned.

Remarks

Only uppercase letters are converted to lowercase; all lowercase letters and nonletter characters remain unchanged.


 Left function

Left function

Returns a Variant (String) containing a specified number of characters from the left side of a string.

Syntax

Left(string, length)

The Left function syntax has these named arguments:

Part | Description
string | Required. String expression from which the leftmost characters are returned. If string contains Null, Null is returned.
length | Required; Variant (Long). Numeric expression indicating how many characters to return. If 0, a zero-length string ("") is returned. If greater than or equal to the number of characters in string, the entire string is returned.

Remarks

To determine the number of characters in string, use the Len function.


 Len function

Len function

Returns a Long containing the number of characters in a string.

Syntax

Len(string)

The Len function syntax has these parts:

Part | Description
string | Any valid String expression. If string contains Null, Null is returned.


 Log function

Log function

Returns a Double specifying the natural logarithm of a number.

Syntax

Log(number)

The required number argument is a Double or any valid numeric expression greater than zero.

Remarks

The natural logarithm is the logarithm to the base e. E is approximately 2.718282.

You can calculate base-n logarithms for any number x by dividing the natural logarithm of x by the natural logarithm of n as follows:

Logn(x) = Log(x) / Log(n)

The following example illustrates a formula field that calculates base-10 logarithms for a number field X:

    Log([X]) / Log(10)


 LTrim, RTrim, and Trim functions

LTrim, RTrim, and Trim functions

Returns a Variant (String) containing a copy of a specified string without leading spaces (LTrim), trailing spaces (RTrim), or both leading and trailing spaces (Trim).

Syntax

LTrim(string)

RTrim(string)

Trim(string)

The required string argument is any valid String expression. If string contains Null, Null is returned.


Math functions

Abs function

Atn function

Cos function

Exp function

Fix function

Int function

Log function

Rnd function

Sgn function

Sin function

Sqr function

Tan function

Derived math functions


 Mid function

Mid function

Returns a Variant (String) containing a specified number of characters from a string.

Syntax

Mid(string, start[, length])

The Mid function syntax has these named arguments:

Part | Description
string | Required. String expression from which characters are returned. If string contains Null, Null is returned.
start | Required; Long. Character position in string at which the part to be taken begins. If start is greater than the number of characters in string, Mid returns a zero-length string ("").
Length | Optional; Variant (Long). Number of characters to return. If omitted or if there are fewer than length characters in the text (including the character at start), all characters from the start position to the end of the string are returned.

Remarks

To determine the number of characters in string, use the Len function.


 Minute function

Minute function

Returns a Variant (Integer) specifying a whole number between 0 and 59, inclusive, representing the minute of the hour.

Syntax

Minute(time)

The required time argument is any Variant, numeric expression, string expression, or any combination, that can represent a time. If time contains Null, Null is returned.


 Month function

Month function

Returns a Variant (Integer) specifying a whole number between 1 and 12, inclusive, representing the month of the year.

Syntax

Month(date)

The required date argument is any Variant, numeric expression, string expression, or any combination, that can represent a date. If date contains Null, Null is returned.


Named Date/Time formats (Format function)

The following table identifies the predefined date and time format names:

Format Name | Description
General Date | Display a date and/or time. For real numbers, display a date and time (for example, 4/3/93 05:34 PM); if there is no fractional part, display only a date (for example, 4/3/93); if there is no integer part, display time only (for example, 05:34 PM). Date display is determined by your system settings.
Long Date | Display a date according to your system's long date format.
Medium Date | Display a date using the medium date format appropriate for the language version of Outlook you use. For example, the English-U.S. version includes the day, month, and year (for example, 05-Jan-96).
Short Date | Display a date using your system's short date format.
Long Time | Display a time using your system's long time format: includes hours, minutes, seconds.
Medium Time | Display time in 12-hour format using hours and minutes and the AM/PM designator.
Short Time | Display a time using the 24-hour format (for example, 17:45).


 Named numeric formats (Format function)

Named numeric formats (Format function)

The following table identifies the predefined numeric format names:

Format name | Description
General Number | Display number, with no thousand separator.
Currency | Display number with thousand separator, if appropriate; display two digits to the right of the decimal separator. Output is based on system locale settings.
Fixed | Display at least one digit to the left and two digits to the right of the decimal separator.
Standard | Display number with thousand separator, at least one digit to the left and two digits to the right of the decimal separator.
Percent | Display number multiplied by 100 with a percent sign (%) appended to the right; always display two digits to the right of the decimal separator.
Scientific | Use standard scientific notation.
Yes/No | Display No if number is 0; otherwise, display Yes.
True/False | Display False if number is 0; otherwise, display True.
On/Off | Display Off if number is 0; otherwise, display On.


Now function

Returns a Variant (Date) specifying the current date and time according your computer's system date and time.

Syntax

Now( )


 NPer function

NPer function

Returns a Double specifying the number of periods for an annuity based on periodic, constant payments and a constant interest rate.

Syntax

NPer(rate, pmt, pv[, fv[, type]])

The NPer function has these named arguments:

Part | Description
rate | Required. Double specifying interest rate per period. For example, if you get a car loan at an annual percentage rate (APR) of 10 percent and make monthly payments, the rate per period is 0.1/12, or 0.0083.
pmt | Required. Double specifying payment to be made each period. Payments usually contain principal and interest that doesn't change over the life of the annuity.
pv | Required. Double specifying present value, or value today, of a series of future payments or receipts. For example, when you borrow money to buy a car, the loan amount is the present value to the lender of the monthly car payments you will make.
fv | Optional. Variant specifying future value or cash balance you want after you've made the final payment. For example, the future value of a loan is $0 because that's its value after the final payment. However, if you want to save $50,000 over 18 years for your child's education, then $50,000 is the future value. If omitted, 0 is assumed.
type | Optional. Variant specifying when payments are due. Use 0 if payments are due at the end of the payment period, or use 1 if payments are due at the beginning of the period. If omitted, 0 is assumed.

Remarks

An annuity is a series of constant cash payments made over a period of time. An annuity can be a loan (such as a home mortgage) or an investment (such as a monthly savings plan).

For all arguments, cash paid out (such as deposits to savings) is represented by negative numbers; cash received (such as dividend checks) is represented by positive numbers.


 Oct function

Oct function

Returns a Variant (String) representing the octal value of a number.

Syntax

Oct(number)

The required number argument is any valid numeric expression or String expression.

Remarks

If number is not already a whole number, it is rounded to the nearest whole number before being evaluated.

If number is | Oct returns
Null | Null.
Empty | Zero (0).
Any other number | Up to 11 octal characters.

You can represent octal numbers directly by preceding numbers in the proper range with &O. For example, &O10 is the octal notation for decimal 8.


 Pmt function

Pmt function

Returns a Double specifying the payment for an annuity based on periodic, constant payments and a constant interest rate.

Syntax

Pmt(rate, nper, pv[, fv[, type]])

The Pmt function has these named arguments:

Part | Description
rate | Required. Double specifying interest rate per period. For example, if you get a car loan at an annual percentage rate (APR) of 10 percent and make monthly payments, the rate per period is 0.1/12, or 0.0083.
nper | Required. Integer specifying total number of payment periods in the annuity. For example, if you make monthly payments on a four-year car loan, your loan has a total of 4 * 12 (or 48) payment periods.
pv | Required. Double specifying present value (or lump sum) that a series of payments to be paid in the future is worth now. For example, when you borrow money to buy a car, the loan amount is the present value to the lender of the monthly car payments you will make.
fv | Optional. Variant specifying future value or cash balance you want after you've made the final payment. For example, the future value of a loan is $0 because that's its value after the final payment. However, if you want to save $50,000 over 18 years for your child's education, then $50,000 is the future value. If omitted, 0 is assumed.
type | Optional. Variant specifying when payments are due. Use 0 if payments are due at the end of the payment period, or use 1 if payments are due at the beginning of the period. If omitted, 0 is assumed.

Remarks

An annuity is a series of constant cash payments made over a period of time. An annuity can be a loan (such as a home mortgage) or an investment (such as a monthly savings plan).

The arguments rate and nper must be calculated using payment periods expressed in the same units. For example, if rate is calculated using months, nper must also be calculated using months.

For all arguments, cash paid out (such as deposits to savings) is represented by negative numbers; cash received (such as dividend checks) is represented by positive numbers.


 PPmt function

PPmt function

Returns a Double specifying the principal payment for a given period of an annuity based on periodic, constant payments and a constant interest rate.

Syntax

PPmt(rate, per, nper, pv[, fv[, type]])

The PPmt function has these named arguments:

Part | Description
rate | Required. Double specifying interest rate per period. For example, if you get a car loan at an annual percentage rate (APR) of 10 percent and make monthly payments, the rate per period is 0.1/12, or 0.0083.
per | Required. Integer specifying payment period in the range 1 through nper.
nper | Required. Integer specifying total number of payment periods in the annuity. For example, if you make monthly payments on a four-year car loan, your loan has a total of 4 * 12 (or 48) payment periods.
pv | Required. Double specifying present value, or value today, of a series of future payments or receipts. For example, when you borrow money to buy a car, the loan amount is the present value to the lender of the monthly car payments you will make.
fv | Optional. Variant specifying future value or cash balance you want after you've made the final payment. For example, the future value of a loan is $0 because that's its value after the final payment. However, if you want to save $50,000 over 18 years for your child's education, then $50,000 is the future value. If omitted, 0 is assumed.
type | Optional. Variant specifying when payments are due. Use 0 if payments are due at the end of the payment period, or use 1 if payments are due at the beginning of the period. If omitted, 0 is assumed.

Remarks

An annuity is a series of constant cash payments made over a period of time. An annuity can be a loan (such as a home mortgage) or an investment (such as a monthly savings plan).

The arguments rate and nper must be calculated using payment periods expressed in the same units. For example, if rate is calculated using months, nper must also be calculated using months.

For all arguments, cash paid out (such as deposits to savings) is represented by negative numbers; cash received (such as dividend checks) is represented by positive numbers.


 PV function

PV function

Returns a Double specifying the present value of an annuity based on periodic, constant payments to be paid in the future and a constant interest rate.

Syntax

PV(rate, nper, pmt[, fv[, type]])

The PV function has these named arguments:

Part | Description
rate | Required. Double specifying interest rate per period. For example, if you get a car loan at an annual percentage rate (APR) of 10 percent and make monthly payments, the rate per period is 0.1/12, or 0.0083.
nper | Required. Integer specifying total number of payment periods in the annuity. For example, if you make monthly payments on a four-year car loan, your loan has a total of 4 * 12 (or 48) payment periods.
pmt | Required. Double specifying payment to be made each period. Payments usually contain principal and interest that doesn't change over the life of the annuity.
fv | Optional. Variant specifying future value or cash balance you want after you've made the final payment. For example, the future value of a loan is $0 because that's its value after the final payment. However, if you want to save $50,000 over 18 years for your child's education, then $50,000 is the future value. If omitted, 0 is assumed.
type | Optional. Variant specifying when payments are due. Use 0 if payments are due at the end of the payment period, or use 1 if payments are due at the beginning of the period. If omitted, 0 is assumed.

Remarks

An annuity is a series of constant cash payments made over a period of time. An annuity can be a loan (such as a home mortgage) or an investment (such as a monthly savings plan).

The arguments rate and nper must be calculated using payment periods expressed in the same units. For example, if rate is calculated using months, nper must also be calculated using months.

For all arguments, cash paid out (such as deposits to savings) is represented by negative numbers; cash received (such as dividend checks) is represented by positive numbers.


 Rate function

Rate function

Returns a Double specifying the interest rate per period for an annuity.

Syntax

Rate(nper, pmt, pv[, fv[, type[, guess]]])

The Rate function has these named arguments:

Part | Description
nper | Required. Double specifying total number of payment periods in the annuity. For example, if you make monthly payments on a four-year car loan, your loan has a total of 4 * 12 (or 48) payment periods.
pmt | Required. Double specifying payment to be made each period. Payments usually contain principal and interest that doesn't change over the life of the annuity.
pv | Required. Double specifying present value, or value today, of a series of future payments or receipts. For example, when you borrow money to buy a car, the loan amount is the present value to the lender of the monthly car payments you will make.
fv | Optional. Variant specifying future value or cash balance you want after you've made the final payment. For example, the future value of a loan is $0 because that's its value after the final payment. However, if you want to save $50,000 over 18 years for your child's education, then $50,000 is the future value. If omitted, 0 is assumed.
type | Optional. Variant specifying Number indicating when payments are due. Use 0 if payments are due at the end of the payment period, or use 1 if payments are due at the beginning of the period. If omitted, 0 is assumed.
guess | Optional. Variant specifying value you estimate will be returned by Rate. If omitted, guess is 0.1 (10 percent).

Remarks

An annuity is a series of constant cash payments made over a period of time. An annuity can be a loan (such as a home mortgage) or an investment (such as a monthly savings plan).

For all arguments, cash paid out (such as deposits to savings) is represented by negative numbers; cash received (such as dividend checks) is represented by positive numbers.

Rate is calculated by iteration. Starting with the value of guess, Rate cycles through the calculation until the result is accurate to within 0.00001 percent. If Rate can't find a result after 20 tries, it fails. If your guess is 10 percent and Rate fails, try a different value for guess.


 Returns for CStr

Returns for CStr

If expression is | CStr returns
Date | A String containing a date in the short-date format of your system.
Null | A run-time error.
Empty | A zero-length String ("").
Error | A String containing the word Error followed by the error number.
Other numeric | A String containing the number.


 Right function

Right function

Returns a Variant (String) containing a specified number of characters from the right side of a string.

Syntax

Right(string, length)

The Right function syntax has these named arguments:

Part | Description
string | Required. String expression from which the rightmost characters are returned. If string contains Null, Null is returned.
length | Required; Variant (Long) . Numeric expression indicating how many characters to return. If 0, a zero-length string ("") is returned. If greater than or equal to the number of characters in string, the entire string is returned.

Remarks

To determine the number of characters in string, use the Len function.


 Rnd function

Rnd function

Returns a Single containing a random number.

Syntax

Rnd[(number)]

The optional number argument is a Single or any valid numeric expression.

Return Values

If number is | Rnd generates
Less than zero | The same number every time, using number as the seed.
Greater than zero | The next random number in the sequence.
Equal to zero | The most recently generated number.
Not supplied | The next random number in the sequence.

Remarks

The Rnd function returns a value less than 1 but greater than or equal to zero.

The value of number determines how Rnd generates a random number:

For any given initial seed, the same number sequence is generated because each successive call to the Rnd function uses the previous number as a seed for the next number in the sequence.

To produce random integers in a given range, use this formula:

Int(([upperbound] - [lowerbound] + 1) * Rnd + [lowerbound])

Here, upperbound is a field with the highest number in the range, and lowerbound is a field with the lowest number in the range.


Rounding

CInt and CLng differ from the Fix and Int functions, which truncate, rather than round, the fractional part of a number. When the fractional part is exactly 0.5, CInt and CLng always round it to the nearest even number. For example, 0.5 rounds to 0, and 1.5 rounds to 2.. Also, Fix and Int always return a value of the same type as is passed in.


 Second function

Second function

Returns a Variant (Integer) specifying a whole number between 0 and 59, inclusive, representing the second of the minute.

Syntax

Second(time)

The required time argument is any Variant, numeric expression, string expression, or any combination, that can represent a time. If time contains Null, Null is returned.


 Sgn function

Sgn function

Returns a Variant (Integer) indicating the sign of a number.

Syntax

Sgn(number)

The required number argument can be any valid numeric expression.

Return Values

If number is | Sgn returns
Greater than zero | 1
Equal to zero | 0
Less than zero | -1

Remarks

The sign of the number argument determines the return value of the Sgn function.


 Sin function

Sin function

Returns a Double specifying the sine of an angle.

Syntax

Sin(number)

The required number argument is a Double or any valid numeric expression that expresses an angle in radians.

Remarks

The Sin function takes an angle and returns the ratio of two sides of a right triangle. The ratio is the length of the side opposite the angle divided by the length of the hypotenuse.

The result lies in the range -1 to 1.

To convert degrees to radians, multiply degrees by pi/180. To convert radians to degrees, multiply radians by 180/pi.


 SLN function

SLN function

Returns a Double specifying the straight-line depreciation of an asset for a single period.

Syntax

SLN(cost, salvage, life)

The SLN function has these named arguments:

Part | Description
cost | Required. Double specifying initial cost of the asset.
salvage | Required. Double specifying value of the asset at the end of its useful life.
life | Required. Double specifying length of the useful life of the asset.

Remarks

The period for which the depreciation is returned is expressed in the same unit of time as the useful life of the asset. All arguments must be positive numbers.


 Space function

Space function

Returns a Variant (String) consisting of the specified number of spaces.

Syntax

Space(number)

The required number argument is the number of spaces you want in the string.

Remarks

The Space function is useful for formatting output and clearing data in fixed-length strings.


 Sqr function

Sqr function

Returns a Double specifying the square root of a number.

Syntax

Sqr(number)

The required number argument is a Double or any valid numeric expression greater than or equal to zero.


 Str function

Str function

Returns a Variant (String) representation of a number.

Syntax

Str(number)

The required number argument is a Long containing any valid numeric expression.

Remarks

When numbers are converted to strings, a leading space is always reserved for the sign of number. If number is positive, the returned string contains a leading space and the plus sign is implied.

Use the Format function to convert numeric values you want formatted as dates, times, or currency or in other user-defined formats. Unlike Str, the Format function doesn't include a leading space for the sign of number.

Note The Str function recognizes only the period (.) as a valid decimal separator. When different decimal separators may be used (for example, in international applications), use CStr to convert a number to a string.


 StrComp function

StrComp function

Returns a Variant (Integer) indicating the result of a string comparison.

Syntax

StrComp(string1, string2[, compare])

The StrComp function syntax has these named arguments:

Part | Description
string1 | Required. Any valid String expression.
string2 | Required. Any valid String expression.
compare | Optional. Specifies the type of string comparison. The compare argument can be omitted, or it can be 0 or 1. Specify 0 (default) to perform a binary comparison. Specify 1 to perform a textual comparison. If compare is Null, an error occurs. If compare is omitted, the comparison method is binary.

Return Values

If | StrComp returns
string1 is less than string2 | -1
string1 is equal to string2 | 0
string1 is greater than string2 | 1
string1 or string2 is Null | Null


 String function

String function

Returns a Variant (String) containing a repeating character string of the length specified.

Syntax

String(number, character)

The String function syntax has these named arguments:

Part | Description
number | Required; Long. Length of the returned string. If number contains Null, Null is returned.
character | Required; Variant. Character code specifying the character or string expression whose first character is used to build the return string. If character contains Null, Null is returned.

Remarks

If you specify a number for character greater than 255, String converts the number to a valid character code using the formula:

character Mod 256


 Switch function

Switch function

Evaluates a list of expressions and returns a Variant value or an expression associated with the first expression in the list that is True.

Syntax

Switch(expr-1, value-1[, expr-2, value-2 … [, expr-n, value-n]])

The Switch function syntax has these parts:

Part | Description
expr | Required. Variant expression you want to evaluate.
value | Required. Value or expression to be returned if the corresponding expression is True.

Remarks

The Switch function argument list consists of pairs of expressions and values. The expressions are evaluated from left to right, and the value associated with the first expression to evaluate to True is returned. If the parts aren't properly paired, a run-time error occurs. For example, if expr-1 is True, Switch returns value-1. If expr-1 is False, but expr-2 is True, Switch returns value-2, and so on.

Switch returns a Null value if:

  • None of the expressions is True.

  • The first True expression has a corresponding value that is Null.

Switch evaluates all of the expressions, even though it returns only one of them. For this reason, you should watch for undesirable side effects. For example, if the evaluation of any expression results in a division by zero error, an error occurs.


 SYD function

SYD function

Returns a Double specifying the sum-of-years' digits depreciation of an asset for a specified period.

Syntax

SYD(cost, salvage, life, period)

The SYD function has these named arguments:

Part | Description
cost | Required. Double specifying initial cost of the asset.
salvage | Required. Double specifying value of the asset at the end of its useful life.
life | Required. Double specifying length of the useful life of the asset.
period | Required. Double specifying period for which asset depreciation is calculated.

Remarks

The arguments life and period must be expressed in the same units. For example, if life is given in months, period must also be given in months. All arguments must be positive numbers.


 Tan function

Tan function

Returns a Double specifying the tangent of an angle.

Syntax

Tan(number)

The required number argument is a Double or any valid numeric expression that expresses an angle in radians.

Remarks

Tan takes an angle and returns the ratio of two sides of a right triangle. The ratio is the length of the side opposite the angle divided by the length of the side adjacent to the angle.

To convert degrees to radians, multiply degrees by pi/180. To convert radians to degrees, multiply radians by 180/pi.


Time function

Returns a Variant (Date) indicating the current system time.

Syntax

Time( )


Timer function

Returns a Single representing the number of seconds elapsed since midnight.

Syntax

Timer( )


 TimeSerial function

TimeSerial function

Returns a Variant (Date) containing the time for a specific hour, minute, and second.

Syntax

TimeSerial(hour, minute, second)

The TimeSerial function syntax has these named arguments:

Part | Description
hour | Required; Variant (Integer). Number between 0 (12:00 A.M.) and 23 (11:00 P.M.), inclusive, or a numeric expression.
minute | Required; Variant (Integer). Any numeric expression.
second | Required; Variant (Integer). Any numeric expression.

Remarks

To specify a time, such as 11:59:59, the range of numbers for each TimeSerial argument should be in the normal range for the unit; that is, 0 – 23 for hours and 0 – 59 for minutes and seconds. However, you can also specify relative times for each argument using any numeric expression that represents some number of hours, minutes, or seconds before or after a certain time. The following example uses expressions instead of absolute time numbers. The TimeSerial function returns a time for 15 minutes before (-15) six hours before noon (12 - 6), or 5:45:00 A.M.

TimeSerial(12 - 6, -15, 0)

When any argument exceeds the normal range for that argument, it increments to the next larger unit as appropriate. For example, if you specify 75 minutes, it is evaluated as one hour and 15 minutes. If any single argument is outside the range -32,768 to 32,767, an error occurs. If the time specified by the three arguments causes the date to fall outside the acceptable range of dates, an error occurs.


 TimeValue function

TimeValue function

Returns a Variant (Date) containing the time.

Syntax

TimeValue(time)

The required time argument is normally a string expression representing a time from 0:00:00 (12:00:00 A.M.) to 23:59:59 (11:59:59 P.M.), inclusive. However, time can also be any expression that represents a time in that range. If time contains Null, Null is returned.

Remarks

You can enter valid times using a 12- or 24-hour clock. For example, "2:24PM" and "14:24" are both valid time arguments.

If the time argument contains date information, TimeValue doesn't return it. However, if time includes invalid date information, an error occurs.


 Type conversion functions

Type conversion functions

Each function coerces an expression to a specific data type.

Syntax

CCur(expression)

CDate(expression)

CDbl(expression)

CInt(expression)

CLng(expression)

CSng(expression)

CVar(expression)

CStr(expression)

The required argument expression is any String expression or numeric expression.

Remarks

The function name determines the return type as shown in the following:

Function | Return Type | Range for expression argument
CCur | Currency | -922,337,203,685,477.5808 to 922,337,203,685,477.5807.
CDate | Date | Any valid date expression
CDbl | Double | -1.79769313486232E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values.
CInt | Integer | -32,768 to 32,767; fractions are rounded.
CLng | Long | -2,147,483,648 to 2,147,483,647; fractions are rounded.
CSng | Single | -3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values.
CVar | Variant | Same range as Double for numerics. Same range as String for non-numerics.
CStr | String | Returns for CStr depend on the expression argument (as explained below).

If the expression passed to the function is outside the range of the type being converted to, an error occurs.

In general, you can document your code using the data-type conversion functions to show that the result of some operation should be expressed as a particular data type rather than the default data type. For example, use CCur to force currency arithmetic in cases where single-precision, double-precision, or integer arithmetic normally would occur.

You should use the data-type conversion functions instead of Val to provide internationally-aware conversions from one data type to another. For example, when you use CCur, different decimal separators are properly recognized depending on the locale setting of your computer, as are different thousand separators and various currency options.

CInt and CLng differ from the Fix and Int functions, which truncate, rather than round, the fractional part of a number. When the fractional part is exactly 0.5, CInt and CLng always round it to the nearest even number. For example, 0.5 rounds to 0, and 1.5 rounds to 2. Also, Fix and Int always return a value of the same type as is passed in.

Use the IsDate function to determine if date can be converted to a date or time. CDate recognizes date and time literals as well as some numbers that fall within the range of acceptable dates. When converting a number to a date, the whole number portion is converted to a date. Any fractional part of the number is converted to a time of day, starting at midnight.

CDate recognizes date formats according to the locale setting of your system. The correct order of day, month, and year may not be determined if it is provided in a format other than one of the recognized date settings. In addition, a long date format is not recognized if it also contains the day-of-the-week string.


 UCase function

UCase function

Returns a Variant (String) containing the specified string, converted to uppercase.

Syntax

UCase(string)

The required string argument is any valid string expression. If string contains Null, Null is returned.

Remarks

Only lowercase letters are converted to uppercase; all uppercase letters and nonletter characters remain unchanged.


User-defined Date/Time formats

The following are examples of user-defined date and time formats for December 7, 1958:

Format | Display
m/d/yy | 12/7/58
d-mmm | 7-Dec
d-mmmm-yy | 7-December-58
d mmmm | 7 December
mmmm yy | December 58
hh:mm AM/PM | 08:50 PM
h:mm:ss a/p | 8:50:35 p
h:mm | 20:50
h:mm:ss | 20:50:35
m/d/yy h:mm | 12/7/58 20:50


 User-defined Date/Time formats (Format function)

User-defined Date/Time formats (Format function)

The following table identifies characters you can use to create user-defined date/time formats:

Character | Description
: | Time separator. In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings.
/ | Date separator. In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings.
C | Display the date as ddddd and display the time as t t t t t, in that order. Display only date information if there is no fractional part to the date serial number; display only time information if there is no integer portion.
D | Display the day as a number without a leading zero (1 – 31).
Dd | Display the day as a number with a leading zero (01 – 31).
Ddd | Display the day as an abbreviation (Sun – Sat).
dddd | Display the day as a full name (Sunday – Saturday).
Ddddd | Display the date as a complete date (including day, month, and year), formatted according to your system's short date format setting. For Microsoft Windows, the default short date format is m/d/yy.
dddddd | Display a date serial number as a complete date (including day, month, and year) formatted according to the long date setting recognized by your system. For Microsoft Windows, the default long date format is mmmm dd, yyyy.
w | Display the day of the week as a number (1 for Sunday through 7 for Saturday).
ww | Display the week of the year as a number (1 – 53).
m | Display the month as a number without a leading zero (1 – 12). If m immediately follows h or hh, the minute rather than the month is displayed.
mm | Display the month as a number with a leading zero (01 – 12). If m immediately follows h or hh, the minute rather than the month is displayed.
mmm | Display the month as an abbreviation (Jan – Dec).
mmmm | Display the month as a full month name (January – December).
q | Display the quarter of the year as a number (1 – 4).
y | Display the day of the year as a number (1 – 366).
yy | Display the year as a 2-digit number (00 – 99).
yyyy | Display the year as a 4-digit number (100 – 9999).
h | Display the hour as a number without leading zeros (0 – 23).
hh | Display the hour as a number with leading zeros (00 – 23).
n | Display the minute as a number without leading zeros (0 – 59).
nn | Display the minute as a number with leading zeros (00 – 59).
s | Display the second as a number without leading zeros (0 – 59).
ss | Display the second as a number with leading zeros (00 – 59).
t t t t t | Display a time as a complete time (including hour, minute, and second), formatted using the time separator defined by the time format recognized by your system. A leading zero is displayed if the leading zero option is selected and the time is before 10:00 A.M. or P.M. The Microsoft Windows default time format is h:mm:ss.
AM/PM | Use the 12-hour clock and display an uppercase AM with any hour before noon; display an uppercase PM with any hour between noon and 11:59 P.M.
am/pm | Use the 12-hour clock and display a lowercase AM with any hour before noon; display a lowercase PM with any hour between noon and 11:59 P.M.
A/P | Use the 12-hour clock and display an uppercase A with any hour before noon; display an uppercase P with any hour between noon and 11:59 P.M.
a/p | Use the 12-hour clock and display a lowercase A with any hour before noon; display a lowercase P with any hour between noon and 11:59 P.M.
AMPM | Use the 12-hour clock and display the AM string literal as defined by your system with any hour before noon; display the PM string literal as defined by your system with any hour between noon and 11:59 P.M. AMPM can be either uppercase or lowercase, but the case of the string displayed matches the string as defined by your system settings. For Microsoft Windows, the default format is AM/PM.


 User-defined numeric format expressions

User-defined numeric format expressions

The following table contains some sample format expressions for numbers. (These examples all assume that your system's locale setting is English-U.S.) The first column contains the format strings; the other columns contain the output that results if the formatted data has the value given in the column headings.

Format (format) | Positive 5 | Negative 5 | Decimal .5 | Null
Zero-length string | 5 | -5 | 0.5 |
0 | 5 | -5 | 1 |
0.00 | 5.00 | -5.00 | 0.50 |
#,##0 | 5 | -5 | 1 |
#,##0.00;;;Nil | 5.00 | -5.00 | 0.50 | Nil
$#,##0;($#,##0) | $5 | ($5) | $1 |
$#,##0.00;($#,##0.00) | $5.00 | ($5.00) | $0.50 |
0% | 500% | -500% | 50% |
0.00% | 500.00% | -500.00% | 50.00% |
0.00E+00 | 5.00E+00 | -5.00E+00 | 5.00E-01 |
0.00E-00 | 5.00E00 | -5.00E00 | 5.00E-01 |


 User-defined numeric formats (Format function)

User-defined numeric formats (Format function)

The following table identifies characters you can use to create user-defined number formats:

Character | Description
None | No formatting
 | Display the number with no formatting.
0 | Digit placeholder
 | Display a digit or a zero. If the expression has a digit in the position where the 0 appears in the format string, display it; otherwise, display a zero in that position.
 | If the number has fewer digits than there are zeros (on either side of the decimal) in the format expression, display leading or trailing zeros. If the number has more digits to the right of the decimal separator than there are zeros to the right of the decimal separator in the format expression, round the number to as many decimal places as there are zeros. If the number has more digits to the left of the decimal separator than there are zeros to the left of the decimal separator in the format expression, display the extra digits without modification.
# | Digit placeholder
 | Display a digit or nothing. If the expression has a digit in the position where the # appears in the format string, display it; otherwise, display nothing in that position.
 | This symbol works like the 0 digit placeholder, except that leading and trailing zeros aren't displayed if the number has the same or fewer digits than there are # characters on either side of the decimal separator in the format expression.
. | Decimal placeholder
 | In some locales, a comma is used as the decimal separator. The decimal placeholder determines how many digits are displayed to the left and right of the decimal separator. If the format expression contains only number signs to the left of this symbol, numbers smaller than 1 begin with a decimal separator. To display a leading zero displayed with fractional numbers, use 0 as the first digit placeholder to the left of the decimal separator. The actual character used as a decimal placeholder in the formatted output depends on the Number Format recognized by your system.
% | Percentage placeholder
 | The expression is multiplied by 100. The percent character (%) is inserted in the position where it appears in the format string.
, | Thousand separator
 | In some locales, a period is used as a thousand separator. The thousand separator separates thousands from hundreds within a number that has four or more places to the left of the decimal separator. Standard use of the thousand separator is specified if the format contains a thousand separator surrounded by digit placeholders (0 or #). Two adjacent thousand separators or a thousand separator immediately to the left of the decimal separator (whether or not a decimal is specified) means "scale the number by dividing it by 1000, rounding as needed." For example, you can use the format string "##0,," to represent 100 million as 100. Numbers smaller than 1 million are displayed as 0. Two adjacent thousand separators in any position other than immediately to the left of the decimal separator are treated simply as specifying the use of a thousand separator. The actual character used as the thousand separator in the formatted output depends on the Number Format recognized by your system.
: | Time separator
 | In some locales, other characters may be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings.
/ | Date separator
 | In some locales, other characters may be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings.
E- E+ e- e+ | Scientific format
 | If the format expression contains at least one digit placeholder (0 or #) to the right of E-, E+, e-, or e+, the number is displayed in scientific format and E or e is inserted between the number and its exponent. The number of digit placeholders to the right determines the number of digits in the exponent. Use E- or e- to place a minus sign next to negative exponents. Use E+ or e+ to place a minus sign next to negative exponents and a plus sign next to positive exponents.
- + $ ( ) space | Display a literal character
 | To display a character other than one of those listed, precede it with a backslash (\) or enclose it in double quotation marks (" ").
\ | Display the next character in the format string
 | To display a character that has special meaning as a literal character, precede it with a backslash (\) . The backslash itself isn't displayed. Using a backslash is the same as enclosing the next character in double quotation marks. To display a backslash, use two backslashes (\\).
 | Examples of characters that can't be displayed as literal characters are the date-formatting and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, y, and /:), the numeric-formatting characters (#, 0, %, E, e, comma, and period), and the string-formatting characters (@, &, <, >, and !).
"ABC" | Display the string inside the double quotation marks
 | To include a string in format from within the formula, you must use Chr(34) to enclose the text (34 is the character code for a double quotation mark (" ")).


 User-defined String formats (Format function)

User-defined String formats (Format function)

You can use any of the following characters to create a format expression for strings:

Character | Description
@ | Character placeholder
 | Display a character or a space. If the string has a character in the position where the @ appears in the format string, display it; otherwise, display a space in that position. Placeholders are filled from right to left unless there is an ! character in the format string.
& | Character placeholder
 | Display a character or nothing. If the string has a character in the position where the & appears, display it; otherwise, display nothing. Placeholders are filled from right to left unless there is an ! character in the format string.
< | Force lowercase
 | Display all characters in lowercase format.
> | Force uppercase
 | Display all characters in uppercase format.
! | Force left to right fill of placeholders
 | The default is to fill from right to left.


 Val function

Val function

Returns the numbers contained in a string as a numeric value of appropriate type.

Syntax

Val(string)

The required string argument is any valid string expression.

Remarks

The Val function stops reading the string at the first character it can't recognize as part of a number. Symbols and characters that are often considered parts of numeric values, such as dollar signs and commas, are not recognized. However, the function recognizes radix prefixes &O (for octal) and &H (for hexadecimal). Blanks, tabs, and linefeeds are stripped from the argument.

The following returns the value 168:

Val("    16 8th Street N.")

In the example below, Val returns the decimal value -1 for the hexadecimal value shown:

Val("&HFFFF")

Note The Val function recognizes only the period (.) as a valid decimal separator. When a possibility exists that different decimal separators may be used (for example, in international applications), you should use CDbl instead to convert a string to a number.


 Weekday function

Weekday function

Returns a Variant (Integer) containing a whole number representing the day of the week.

Syntax

Weekday(date, [firstdayofweek])

The Weekday function syntax has these named arguments:

Part | Description
date | Required. Variant, numeric expression, string expression, or any combination, that can represent a date. If date contains Null, Null is returned.
Firstdayofweek | Optional. Specifies the first day of the week. If not specified, Sunday is assumed.

Settings

The firstdayofweek argument has these settings:

Value | Description
0 | Use the NLS API setting.
1 | Sunday (default)
2 | Monday
3 | Tuesday
4 | Wednesday
5 | Thursday
6 | Friday

7 Saturday

Return Values

The Weekday function can return any of these values:

Value | Description
1 | Sunday
2 | Monday
3 | Tuesday
4 | Wednesday
5 | Thursday
6 | Friday
7 | Saturday


 Year function

Year function

Returns a Variant (Integer) containing a whole number representing the year.

Syntax

Year(date)

The required date argument is any Variant, numeric expression, string expression, or any combination, that can represent a date. If date contains Null, Null is returned.


Add other custom controls to the Control Toolbox

  1. Right-click any control or an empty area on any page of the Control Toolbox, and then click Custom Controls on the shortcut menu.

  2. In the Available Controls box, select the check box next to the controls that you want to add.


 Add a custom button or menu command to start a reply form

Add a custom button or menu command to start a reply form

  1. In design mode, click the Actions page of your form.

  2. Click an action that you created, and then click the Properties button.

  3. Select the Show action on check box.

  4. Click Menu and Toolbar to add both a button and a menu command.

    Click Menu only to add a menu command only.

    The text in the Action name box is used as the command name or button name on the form.

Note The menu command is added to the Actions menu for message forms, the Contact menu for contact forms, and the Appointment menu for appointment forms.


 Add a modified control to the Control Toolbox

Add a modified control to the Control Toolbox

  1. If the Control Toolbox is not visible, click Control Toolbox [image] .

  2. Drag a control from the Control Toolbox to your form and customize it.

    For example, to create an OK button, drag a CommandButton onto the form, set its Caption property to OK, and set its Default property to True.

  3. Select the customized control.

  4. Drag the control to the Control Toolbox.

Note When you drag a control onto the Control Toolbox, you only transfer the advanced property values. Any code or Outlook property values you have written for that control do not transfer with the control. You must write new code for the icon or copy code from the control on the form to the control on the Control Toolbox. For information about how to set properties for controls, click [image] .


 Add items to a list at run time

Add items to a list at run time

In a ListBox or ComboBox with a single column, use the AddItem method to add an individual entry to the list.

In a multicolumn list box or combo box, you can use the List and Column properties to load the list from a two-dimensional array, as shown in the following steps.

  1. Create a multicolumn ListBox or ComboBox control.

  2. In VBScript, create a two-dimensional array that contains the items you want to put in the list.

  3. Set the ColumnCount property of the list box or combo box to match the number of entries in the list. To set the property, click the property and enter a value in the Apply box.

  4. Do one of the following:
    • Assign the array as the value of the List property. The contents of the list box will match the contents of the array exactly.

    • Assign the array as the value of the Column property. Column transposes rows and columns, so each row of the list box matches the corresponding column of the array.


 Add or remove controls on a form

Add or remove controls on a form

With the form in design mode:

  1. To add a control, click Control Toolbox [image] , and then drag the control to the form.

  2. Set control properties.

    How?

  3. To remove a control, right-click the control, and then click Delete on the shortcut menu.


 Automatically calculate the result of a field

Automatically calculate the result of a field

  1. In design mode, right-click the control that is bound to the field whose properties you want to change, and then click Properties on the shortcut menu.

  2. On the Value tab, select the Set the initial value of this field to check box.

  3. In the box below enter the name of the field you want to use.

  4. Click Calculate this formula automatically.

  5. To make the control read-only, click the Display tab, and then select the Read only check box.


 Automatically insert text into the Subject field of a reply form

Automatically insert text into the Subject field of a reply form

  1. In design mode, click the Actions page of your form.

  2. Click the action to which you want to add the prefix text, and then click the Properties button.

  3. In the Subject prefix box, type the text as you want it to appear (Outlook automatically adds a colon after the text).

    For example, you could add the prefix Re: to a reply form.


 Bind a control to a field

Bind a control to a field

If you have created a control using the Control Toolbox and you would like the information in this control to be saved with the form, the control must be bound to a field. This means that a link will be established between the control and the source of data, in this case, a field in the item.

  1. In design mode, right-click the control you want to bind to a field and then click Properties on the shortcut menu.

  2. On the Value tab, click Choose Field, point to a field set, and then click the field to which you want to bind the control. If you would like to bind the control to a new field that you create, click New. In the New Field box, type the name of your new field in the Name: area. Click OK in the New Field box.

  3. Click OK in the Properties box.

Note If you bind a ListBox, ComboBox, OptionButton, or CheckBox to a field, then the Click event does not fire. You need to use the PropertyChange or CustomPropertyChange event to detect the change via code.

Example:

Sub Item_PropertyChange(ByVal Name)
Set MyListBox = Item.GetInspector.ModifiedFormPages("Message").Controls("ListBox1")
Select Case Name
    Case "Mileage"
        Item.CC = MyListBox.Value
        Item.Subject = MyListBox.Value
    Case Else
End Select
End Sub


ByVal References

The ByVal keyword is a way of passing the value, rather than the address, of an argument to a procedure. This allows the procedure to access a copy of the variable. As a result, the variable's actual value cannot be changed by the procedure to which it is passed.


 Create a set of OptionButtons using the GroupName property

Create a set of OptionButtons using the GroupName property

  1. Place all required OptionButton controls on the form.

    Note that option buttons in a Page, MultiPage, or Frame automatically form an option group.

  2. For each button in the group, set the GroupName property to the same value.


 Create an Outlook item

Create an Outlook item

This procedure uses the Click event to call CreateItem to create and show an appointment when a user clicks CommandButton1.

In design mode:

  1. Using the Control Toolbox, place a CommandButton on your form.

    How?

  2. Open the Script Editor.

    How?

  3. Enter the following code, using the value from the table below to specify the type of item that you want to create.
    Sub CommandButton1_Click
    Application.CreateItem(1).Display
End Sub
Type of item | Has the value
MailItem | 0
AppointmentItem | 1
ContactItem | 2
TaskItem | 3
JournalItem | 4
NoteItem | 5
PostItem | 6
DistListItem | 7


Change a property of a control

To change a property for one control on a page, use code similar to the following. This example refers to a TextBox on page "P.2" named "TextBox1".

Item.GetInspector.ModifiedFormPages("P.2").TextBox1

To cycle through and change the Visible property on all controls on a page, use code similar to the following.

Set myPage = Item.GetInspector.ModifiedFormPages("P.2")
For i = 0 to myPage.Controls.Count - 1
    myPage.Controls(i).Visible = False
Next


 Create a custom reply form

Create a custom reply form

  1. Create the custom reply form with the options and layout that you want.

  2. Publish the form to your Personal Forms Library.

    How?

  3. Set options on the main form that is associated with the reply form.

    How?


 Make a control transparent

Make a control transparent

  1. Right-click the control you want to make transparent, and then click Advanced Properties on the shortcut menu.

  2. Set the BackStyle property to Transparent. To set the property, click the BackStyle property and then click Transparent in the Apply list. If the control supports the BorderStyle property, set it to None.

Note When you make a control transparent, the background color does not appear, so the BackColor property is ignored. However, the setting for BackColor is not changed when a control is transparent. Learn about transparency.


 Make changes to a custom field in a folder

Make changes to a custom field in a folder

  1. Click the folder for which you want to change the custom field.

  2. On the View menu, point to Current View, and then click a view based on the available view types.

  3. Right-click the column heading of the custom field, and then click Format Columns on the shortcut menu.

  4. Select the options that you want.


 Specify whether a form prompts the user, opens, or is sent

Specify whether a form prompts the user, opens, or is sent

  1. In design mode, click the Actions page of your form.

  2. Click the action that you want, and then click the Properties button.

  3. Under This action will, click the option that you want the form to perform.
Click this option | To
Open the form | Open the form so the user can add information.
Send the form immediately | Send the form to the address specified without opening it.
Prompt the user to open or send | Alert the user with a message that includes the option to open or send the form.

Note If you click Send the form immediately, you must pre-address the form.


Go to a line of code

  1. Open the Script Editor.

    How?

  2. On the Edit menu, click Go To.

  3. In the Line Number box, type in the number of the line of code to which you want to go.


 Disable a standard reply form

Disable a standard reply form

  1. In design mode, click the Actions page of your form.

  2. Click the action that you want, and then click the Properties button.

  3. Clear the Enabled check box.


 How to use the Outlook object browser

How to use the Outlook object browser

To view the Outlook object browser:

1 Open a form in design mode.

2 In the Form menu, click View Code to view the Script Editor.

3 In the Script Editor, click Object Browser on the Script menu or press F2.

All of the available Outlook objects are listed in the Classes pane of the object browser in alphabetical order.

To view the members of an object, select the object in the Classes pane. The members of this object appear in alphabetical order in the Members of pane. The heading at the top of this pane will reflect the name of the object that you select. For example, if you select the AppointmentItem object in the Classes pane, the heading of the Members of pane will appear as Members of AppointmentItem.

The details pane shows the definition of the selected member. This text is read-only and cannot be copied and pasted into the Script Editor.

To insert an item from the object browser into the Script Editor:

1 In the Script Editor, position your cursor at the location for insertion.

2 Select the desired object in the Classes pane.

3 Select the desired member of this object in the Members of pane.

4 Click the Insert button.

Note The Insert button remains unavailable until a member of the object is selected.


 How to use the Outlook script debugger

How to use the Outlook script debugger

To use the script debugger, open a form in design mode.

To add VBScript to the form, on the Form menu, click on View Code. In the Script Editor window, add the necessary VBScript for your form.

For more information about adding VBScript to the form, click here

On the Form menu, click Run This Form.

While your form is in run mode, on the Tools menu, select Forms and click Script Debugger.

You can also use the Stop statement in code to launch the debugger.

Note If there is no VBScript for this form, the Script Debugger menu item will be unavailable.

The VBScript for this form will appear in a read-only window. You cannot change text in this window.

On the Help menu of the Microsoft Script Debugger, select Help Topics for more detailed information about:

  • Debugging scripts

  • Viewing source code

  • Controlling program execution

  • Viewing and changing values

  • Viewing and controlling program flow


 I can't find the form I created

I can't find the form I created

  • The form may be visible only for message responses. To trigger the response form, create a form, such as a new message form, and then send it to yourself. Open the response form, click the (Properties) page, and then clear the Use form only for responses check box. For information about how to open a form, click

  • The form may not have been saved, or it may not have been saved to a forms library. For information about how to save a form, click

  • Based on the item type used, switching to a table view may make it easier to see the form.


Copy a form to another forms library

  1. On the Tools menu, click Options, and then click the Other tab.

  2. Click the Advanced Options button.

  3. Click the Custom Forms button.

  4. Click the Manage Forms button.

  5. To change the forms library, click Set.

  6. In the box on the left, click the form that you want to copy to the forms library shown in the box on the right.

  7. Click Copy.

To copy a form to a Folder Forms Library or to an Organizational Forms Library, you must have appropriate permission.

Note When you copy a form from your Personal Forms Library to a Folder Forms Library or to an Organizational Forms Library, you must change the name or a property of the form. Outlook only updates the forms in your Personal Forms Library if the form from the Folder Forms or Organizational Forms Library has different properties. Learn more about form names and message classes.


 Pre-address a reply form to a public folder or an e-mail address

Pre-address a reply form to a public folder or an e-mail address

To pre-address a form to a public folder, you must first add the public folder to the Address Book.

  1. Open the type of form that you want to pre-address.

  2. On the Tools menu of the form, click Address Book.

  3. In the Type name or select from list box, enter the e-mail address or public folder that you want to appear in the To box on the form, and then click OK.

  4. On the Tools menu of the form, select Forms and click Design This Form to put the form into design mode.

Note The user of the form must have permission to access the public folder to which you pre-address a form. How to set permissions.


 Protect your form from changes

Protect your form from changes

  1. In design mode, click the Properties page.

  2. Select the Protect form design check box.

  3. In the Password box, enter a password.

  4. In the Confirm box, enter the same password again.


 Publish a form

Publish a form

  1. On the Tools menu of the form, select Forms and click Publish Form As.

  2. In the Form Name box, type the name for the form.

    Note For important information about the form name and message class, click here

  3. To change the location (library) where the form is stored, select the folder that you want in the Look In box or click the Browse button.

  4. Click the Publish button.


 Resize a control horizontally and vertically with the form

Resize a control horizontally and vertically with the form

This procedure sets an invisible property. After you complete the procedure, you should remove the code from the Script Editor.

  1. In design mode, select the control, and then size it relative to the form. For example, if you want the control to always be same as the height of the form, make the bottom edge of the control equal to the bottom edge of the form.

  2. On the Form menu, click View Code.

  3. Add the following code to the Script Editor. Replace "TextBox1" with the name of the control you want to resize, and replace "P. 2" with the name of your page. Although this example uses the Write event, you can use any event to run the code.

    Sub Item_Write

    Item.GetInspector.ModifiedFormPages("P.2").TextBox1.LayoutFlags = 65

    End Sub

  4. On the Form menu of the form, click Run This Form.

  5. On the File menu of the form, click Save.

Note To reset the LayoutFlags property, right-click the control, and then click Properties on the shortcut menu. On the Display page, if the Resize with form check box is selected, clear it; if the Resize with form check box is cleared, select it and then clear it.


Resize a control horizontally with the form

  1. Right-click the control, and then click Properties on the shortcut menu.

  2. On the Display tab, select the Resize with form check box.


 Resize a control vertically with the form

Resize a control vertically with the form

This procedure sets an invisible property. After you complete the procedure, you can remove the code from the Script Editor.

  1. In design mode, select the control, and then size it relative to the form. For example, if you want the control to always be the height of the form, make the bottom edge equal to the bottom edge of the form.

  2. On the Form menu, click View Code.

  3. Add the following code to the Script Editor. Replace "TextBox1" with the name of the control you want to resize, and replace "P. 2" with the name of your page. Although this example uses the Write event, you can use any event to run the code.

    Sub Item_Write

    Item.GetInspector.ModifiedFormPages("P.2").TextBox1.LayoutFlags = 68

    End Sub

  4. On the Form menu of the form, click Run This Form.

  5. On the File menu of the form in run mode, click Save.

Note To reset the LayoutFlags property, right-click the control, and then click Properties on the shortcut menu. On the Display page, if the Resize with form check box is selected, clear it; if the Resize with form check box is cleared, select it and then clear it.


Save a form as a file

  1. On the File menu, click Save As.

  2. In the File name box, type a name for the form.

  3. In the Save as type box, click a file type.

    To save the form as an Outlook template, click Outlook Template, and then save the form in the Templates folder.

Learn about form file formats


 Send the form definition with the form

Send the form definition with the form

If you expect to send items using this form to recipients who do not have access to the forms library, you can specify that the form definition be sent along with the item.

  1. In design mode, click the Properties page.

  2. Select the Send form definition with item check box.

For more information about sending form definitions, click here

For more information about setting default properties for a form, click here


 Save a form in the open folder

Save a form in the open folder

  • On the File menu, click Save [image] .


Save a form in a forms library

  1. On the Tools menu, select Forms and then click Publish Form As.

  2. In the Form Name box, type the name for the form.

  3. In the Display Name box, type the display name for the form.

  4. To change the location (library) where the form is stored, choose a new folder in the Look In box or click the browse button and choose a folder.

  5. To save the form in the Organizational Forms Library, click Organizational Forms Library in the Forms Library box.

    To save the form in the Outlook Folders Library, click Outlook Folders and then click the folder where you want the form to be saved.

    To save the form in the Personal Forms Library, click Personal Forms Library.

  6. When you have selected the folder in which you want to publish your form, click Publish.


 Send a form to others by using e-mail

Send a form to others by using e-mail

With the form in design mode:

  1. On the (Properties) tab in the form, select the Send form definition with item check box.

  2. If you have not already done so, save the form in the open folder.

    How?

  3. Close the form, and then create a mail message.

  4. On the Insert menu, click Item, and then click the form that you want to insert.

  5. Click OK, and then click Send [image] .

Tips

  • You can send a form to others outside your organization if the gateways or connectors support attachments in Rich Text Format.


Set the background color of a form

  1. Right-click the form, and then click Advanced Properties on the shortcut menu.

  2. Set the BackColor property. To set the property, click the property and enter a value in the Apply box.


 Create a validation formula and message

Create a validation formula and message

  1. In design mode, right-click the field or control for which you want to create a validation formula, and then click Properties on the shortcut menu.

  2. Click the Validation page.

  3. Select the Validate this field before closing the form check box.

  4. In the Validation Formula box, enter the formula that you want to use for evaluating user input.

  5. In the Display this message if the validation fails box, type the text that you want to appear in the message.


 Set options for the original message text in a reply form

Set options for the original message text in a reply form

  1. In design mode, click the Actions page of your form.

  2. Click the action that you want, and then click the Properties button.

  3. In the When responding box, click an option.
Click | To
Do not include original message | Delete the original text in the message box of the message.
Attach original message | Include the original message as an attachment in the message box of the message.
Include original message text | Include the original message text in the text box of the message exactly how it was written.
Include and indent original message text | Include the original message text and indent it to the right to distinguish it from new text the user adds.
Prefix each line of the original message | Include the original message text in the text box of the message. The text will not be indented but each line of the original message will be prefixed with >.
Attach link to original message | Include a link to the original message.
Respect user's default | Use the user's Tools menu, Options dialog box settings.


 Set options on a form that is associated with a reply form

Set options on a form that is associated with a reply form

  1. In design mode, click the Actions page of your form.

  2. Click New.

  3. In the Action name box, type a name for the menu command and button that you want to use to open the custom reply form.

    For example, if you type Send to Finance in the Action name box, the Read page of the form includes a Send to Finance command on the Actions menu (and a Send to Finance button on the toolbar if you select the option for both).

  4. In the Form name box, type the name of the custom reply form that you want to associate with this form.

  5. Select the Show action on check box, and then click the option that you want.

  6. Under Characteristics of the new form, select the options that you want.

  7. Click OK.

  8. In the list of actions, disable the standard reply actions that you want to remove.

    For example, if you create a custom reply action, you should disable the standard Outlook reply action.

    How?

  9. Open the custom reply form that you associated with this form, and then click the Properties page.

  10. Click the Use form only for responses option.

  11. This removes the form from the forms library list so it cannot be selected by mistake. To edit the form you must make it visible.

    How?


Troubleshoot forms

What do you want help with?

Use an Outlook Form in Microsoft Exchange.

I can't find the form I created.

How can I prevent the VBScript code from running?


Make a hidden form visible

  1. On the Tools menu, click Options, then click the Other tab.

  2. Click the Advanced Options button.

  3. Click the Custom Forms button.

  4. Click the Manage Forms button.

  5. Click the form you want to make visible.

  6. Click the Properties button.

  7. Clear the Hidden check box.


Change the value of a field

To change the value of an Outlook field, use the property name of the associated standard field. For example, to change the value of the Subject field, use the following code.

Item.Subject = "New Subject"

To change the value of a custom field, use the following code to refer to a custom field.

Item.UserProperties.Find("MyProperty").Value = "New Value"


Use a custom color for the background or foreground of a control

  1. Right-click the control, and then click Advanced Properties on the shortcut menu.

  2. Click the BackColor or ForeColor property.

  3. In the top-right corner of the Properties dialog box, click the button with 3 dots.

  4. Click the color you want from the color palette.


Use message boxes to return values

One way to isolate errors is to use a message box to display the value of a variable or property at a particular point in the coce. This code example shows the selection length returned from the SelLength property in a message box.

MsgBox Item.GetInspector.ModifiedFormPages("Test").Textbox1.SelLength


 Use the Outlook Object Browser

Use the Outlook Object Browser

The Outlook object browser displays the classes, properties, methods, events, and constants available from the Outlook object library. The object browser lets you view and use objects in the Script Editor and obtain information about the syntax for using the object.

For more information about viewing and using the Outlook object browser, click here

To view the Outlook object hierarchy, click here

For more information about recent changes to the Outlook object library, click here


 Use an Outlook Form in Microsoft Exchange.

Use an Outlook Form in Microsoft Exchange.

Microsoft Exchange Client does not recognize Outlook forms. A Microsoft Exchange Client user who opens an Outlook Form sees only the standard message form properties; that is, all custom fields are not visible. However, Outlook can open forms designed with the Microsoft Exchange Forms Designer.


Use the PropertyChange event to test procedures

Perform the following steps to test simple procedures. Replace the code below with the code that you want to test. Each time a user changes the value of the Importance field, or any other default field, the code runs.

  1. Open the Script Editor.

    How?

  2. On the Script menu, click Event Handler.

  3. In the Events box, double-click PropertyChange.

  4. Add the following code in the event:

    MsgBox "This is my test procedure"

  5. On the Form menu, click Run This Form.

  6. Click the ! icon on the toolbar. The message box will appear.

  7. Click OK to close the message box.


Use a system color for a background or foreground

  1. Right-click the control, and then click Properties on the shortcut menu.

  2. Click an option in the Foreground color or Background color box.

    A preview of the option that you select appears in the Font box above.


 Use standard Reply and Forward headers on a form

Use standard Reply and Forward headers on a form

  1. In design mode, click the Actions page of your form.

  2. Click an action that you created, and then click the Properties button.

  3. In the Address form like a box, click the header you want to use.
Use this header | To
Reply | Include the sender in the To field and the subject of the message in the Subject field.
Reply to All | Include all the recipients of the message in the To and Cc fields and the subject of the message in the Subject field.
Forward | Include the subject of the message in the Subject field and leave the To field blank.
Reply to Folder | Show the active folder and show the subject as a conversation, and add Subject and Categories fields.
Response | Use the standard response fields.


 Open a task, Calendar item, or note from a custom form

Open a task, Calendar item, or note from a custom form

  1. In design mode, click the Actions page of your form.

  2. Click New.

  3. In the Form name list, click Forms.

  4. In the Look In list, click Standard Forms Library.

  5. In the box below, click the form that you want to use.


 View all standard fields for an item

View all standard fields for an item

  1. Open the item for which you want to show fields.

  2. On the Tools menu, select Forms and click Design This Form, and then click the (All Fields) tab.

  3. In the Select from box, click All ItemName Fields. For example, if this is a mail message, click All Mail fields.

Notes

  • You cannot show all fields for a note or a distribution list.

  • To view all fields in a Contact item, open the item, and then click the All Fields tab.


Add a Click event for a control

  1. Open the Script Editor.

    How?

  2. For the control to which you want to add a Click event, add the following, where CommandButton1 is the name of the control.

    Sub CommandButton1_Click

    End Sub

  3. Enter the code that you want in the event.


Add an Outlook event

  1. Open the Script Editor.

    How?

  2. On the Script menu, click Event Handler.

  3. In the Insert Events Handler box, click the event that you want to use, and then click Add.

Learn more about working with Outlook events.


All functions

Conversion functions

Date/Time functions

Financial functions

General functions

Math functions

Text functions


 + operator

+ operator

Used to sum two numbers.

Syntax

result = expression1+expression2

The + operator syntax has these parts:

Part | Description
result | Any numeric variable.
expression1 | Any expression.
expression2 | Any expression.

Remarks

Use the & operator for concatenation to eliminate ambiguity and provide self-documenting code.

When you use the + operator, you may not be able to determine whether addition or string concatenation will occur. If at least one expression is not a Variant, the following rules apply:

Operation performed | If
Add | Both expressions are numeric data types (Byte, Boolean, Integer, Long, Single, Double, Date, or Currency)
Concatenate | Both expressions are String
Add | One expression is a numeric data type and the other is any Variant except Null
Concatenate | One expression is a String and the other is any Variant except Null
Return the remaining expression unchanged as result | One expression is an Empty Variant
A Type mismatch error occurs | One expression is a numeric data type and the other is a String
result is Null | Either expression is Null

If both expressions are Variant expressions, the following rules apply:

Operation performed | If
Add | Both Variant expressions are numeric
Concatenate | Both Variant expressions are strings
Add | One Variant expression is numeric and the other is a string

For simple arithmetic addition involving only expressions of numeric data types, the data type of result is usually the same as that of the most precise expression. The order of precision, from least to most precise, is Byte, Integer, Long, Single, Double, and Currency. The following are exceptions to this order:

  • When a Single and a Long are added together, the data type of result is converted to a Double.

  • When the data type of result is a Long, Single, or Date variant that overflows its legal range, result is converted to a Double variant.

  • When the data type of result is a Byte variant that overflows its legal range, result is converted to an Integer variant.

  • When the data type of result is an Integer variant that overflows its legal range, result is converted to a Long variant.

  • When a Date is added to any data type, the data type of result is always a Date.

Note The order of precision used by addition and subtraction is not the same as the order of precision used by multiplication.

If one or both expressions are Null expressions, result is Null. If both expressions are Empty, result is an Integer. However, if only one expression is Empty, the other expression is returned unchanged as result.


 And operator

And operator

Used to perform a logical conjunction on two expressions.

Syntax

result = expression1 And expression2

The And operator syntax has these parts:

Part | Description
result | Any numeric variable.
expression1 | Any expression.
expression2 | Any expression.

Remarks

If both expressions evaluate to True, result is True. If either expression evaluates to False, result is False. The following table illustrates how result is determined:

If expression1 is | And expression2 is | The result is
True | True | True
True | False | False
True | Null | Null
False | True | False
False | False | False
False | Null | False
Null | True | Null
Null | False | False
Null | Null | Null

The And operator also performs a bit-wise comparison of identically positioned bits in two numeric expressions and sets the corresponding bit in result according to the following table:

If bit in expression1 is | And bit in expression2 is | The result is
0 | 0 | 0
0 | 1 | 0
1 | 0 | 0
1 | 1 | 1


Arithmetic operators

^ operator

* operator

/ operator

\ operator

Mod operator

+ operator

- operator


 Select the item on which to base a form

Select the item on which to base a form

Each Outlook item is a collection of fields. Some of these collections of fields may be more useful for particular applications than others. To see the complete list of fields for an item, click All in the Field Chooser. For example, to see all the fields in a mail message, click All Mail Fields. If the field you want is not listed, you can create a custom field by clicking New in the Field Chooser.

Use this item | To
Mail Message | Send a form to other people with an associated Reply form so they can send information back.
Post | Send a form to a folder.
Appointment or Meeting Request | Record scheduling information about people, dates, places, and times for an appointment or meeting.
Contact | Record information about a person or organization.
Task or Task Request | Record a personal or work-related duty or errand that you want to track through until completion.
Journal Entry | Record interactions with important contacts, record items or documents that are significant to you, and record activities of all types.


 Comparison operators

Comparison operators

Used to compare expressions.

Syntax

result = expression1 comparisonoperator expression2

result = string Like pattern

Comparison operators have these parts:

Part | Description
expression | Any expression.
comparisonoperator | Any comparison operator.
string | Any string expression.
pattern | Any string expression or range of characters.

Remarks

The Like operator has specific comparison functionality that differs from the operators in the following table. The following table contains a list of the comparison operators and the conditions that determine whether result is True, False, or Null:

Operator | Description | True if | False if | Null if
< | Less than | expression1 < expression2 | expression1 >= expression2 | expression1 or expression2 = Null
<= | Less than or equal to | expression1 <= expression2 | expression1 > expression2 | expression1 or expression2 = Null
> | Greater than | expression1 > expression2 | expression1 <= expression2 | expression1 or expression2 = Null
>= | Greater than or equal to | expression1 >= expression2 | expression1 < expression2 | expression1 or expression2 = Null
= | Equal to | expression1 = expression2 | expression1 <> expression2 | expression1 or expression2 = Null
<> | Not equal to | expression1 <> expression2 | expression1 = expression2 | expression1 or expression2 = Null

When comparing two expressions, you may not be able to easily determine whether the expressions are being compared as numbers or as strings. The following table shows how the expressions are compared or what results when either expression is not a Variant:

If | Then
Both expressions are numeric data types (Byte, Boolean, Integer, Long, Single, Double, Date, or Currency) | Perform a numeric comparison.
Both expressions are String | Perform a string comparison.
One expression is a numeric data type and the other is a Variant that is, or can be, a number | Perform a numeric comparison.
One expression is a numeric data type and the other is a string Variant that can't be converted to a number | Perform a string comparison.
One expression is a String and the other is any Variant (except a Null) | Perform a string comparison.
One expression is Empty and the other is a numeric data type | Perform a numeric comparison, using 0 as the Empty expression.
One expression is Empty and the other is a String | Perform a string comparison, using a zero-length string ("") as the Empty expression.

If expression1 and expression2 are both Variant expressions, their underlying type determines how they are compared. The following table shows how the expressions are compared or what results from the comparison, depending on the underlying type of the Variant:

If | Then
Both Variant expressions are numeric | Perform a numeric comparison.
Both Variant expressions are strings | Perform a string comparison.
One Variant expression is numeric and the other is a string | The numeric expression is less than the string expression.
One Variant expression is Empty and the other is numeric | Perform a numeric comparison, using 0 as the Empty expression.
One Variant expression is Empty and the other is a string | Perform a string comparison, using a zero-length string as the Empty expression.
Both Variant expressions are Empty | The expressions are equal.

Note If a Currency is compared with a Single or Double, the Single or Double is converted to a Currency. This causes any fractional part of the Single or Double value less than 0.0001 to be lost and may cause two values to compare as equal when they are not. When a Single is compared to a Double, the Double is rounded to the precision of the Single.


Concatenation operators

& operator

+ operator


Conversion functions

Asc function

CCur function

CDbl function

Chr function

CInt function

CLng function

CSng function

CStr function

CVar function

DateSerial function

DateValue function

Day function

Hex function

Hour function

Minute function

Month function

Oct function

Second function

Str function

TimeSerial function

TimeValue function

Val function

Weekday function

Year function


Date/Time functions

Date function

DateAdd function

DateDiff function

DatePart function

DateSerial function

DateValue function

Day function

Hour function

IsDate function

Minute function

Month function

Now function

Second function

Time function

Timer function

TimeSerial function

TimeValue function

Weekday function

Year function


Derived math functions

The following is a list of nonintrinsic math functions that can be derived from the intrinsic math functions:

Function | Derived equivalents
Secant | Sec([X]) = 1 / Cos([X])
Cosecant | Cosec([X]) = 1 / Sin([X])
Cotangent | Cotan([X]) = 1 / Tan([X])
Inverse Sine | Arcsin([X]) = Atn([X] / Sqr(-[X] * [X] + 1))
Inverse Cosine | Arccos([X]) = Atn(-[X] / Sqr(-[X] * [X] + 1)) + 2 * Atn(1)
Inverse Secant | Arcsec([X]) = Atn([X] / Sqr([X] * [X] - 1)) + Sgn(([X]) - 1) * (2 * Atn(1))
Inverse Cosecant | Arccosec([X]) = Atn([X] / Sqr([X] * [X] - 1)) + (Sgn([X]) - 1) * (2 * Atn(1))
Inverse Cotangent | Arccotan([X]) = Atn([X]) + 2 * Atn(1)
Hyperbolic Sine | HSin([X]) = (Exp([X]) - Exp(-[X])) / 2
Hyperbolic Cosine | HCos([X]) = (Exp([X]) + Exp(-[X])) / 2
Hyperbolic Tangent | HTan([X]) = (Exp([X]) - Exp(-[X])) / (Exp([X]) + Exp(-[X]))
Hyperbolic Secant | HSec([X]) = 2 / (Exp([X]) + Exp(-[X]))
Hyperbolic Cosecant | HCosec([X]) = 2 / (Exp([X]) - Exp(-[X]))
Hyperbolic Cotangent | HCotan([X]) = (Exp([X]) + Exp(-[X])) / (Exp([X]) - Exp(-[X]))
Inverse Hyperbolic Sine | HArcsin([X]) = Log([X] + Sqr([X] * [X] + 1))
Inverse Hyperbolic Cosine | HArccos([X]) = Log([X] + Sqr([X] * [X] - 1))
Inverse Hyperbolic Tangent | HArctan([X]) = Log((1 + [X]) / (1 - [X])) / 2
Inverse Hyperbolic Secant | HArcsec([X]) = Log((Sqr(-[X] * [X] + 1) + 1) / [X])
Inverse Hyperbolic Cosecant | HArccosec([X]) = Log((Sgn([X]) * Sqr([X] * [X] + 1) + 1) / [X])
Inverse Hyperbolic Cotangent | HArccotan([X]) = Log(([X] + 1) / ([X] - 1)) / 2
Logarithm to base N | LogN([X]) = Log([X]) / Log(N)


Use current user properties from the Microsoft Exchange Server global address list

In code, open an OLE messaging session and log on, and then use the following table to reference the property you want to use.

Set olemSession = Application.CreateObject("MAPI.Session")
ReturnCode = olemSession.Logon( Application.GetNameSpace("MAPI").CurrentUser, "", False, False, 0 )
myPage = Item.GetInspector.ModifiedFormPages("Message")
Set myUser = olemSession.CurrentUser
Item.UserProperties.Find("Name") = myUser.Name
Item.UserProperties.Find("Messaging Address") = myUser.Address
Item.UserProperties.Find("MAPI First Name") = myUser.Fields.item(&h3a06001e)
Address Book Property | Reference
PR_GIVEN_NAME | &h3a06001e
PR_INITIALS | &h3a0a001e
PR_SURNAME | &h3a11001e
PR_7BIT_DISPLAY_NAME | &h39ff001e
PR_STREET_ADDRESS | &h3a29001e
PR_LOCALITY | &h3a27001e
PR_STATE_OR_PROVINCE | &h3a28001e
PR_POSTAL_CODE | &h3a2a001e
PR_COUNTRY | &h3a26001e
PR_TITLE | &h3a17001e
PR_COMPANY_NAME | &h3a16001e
PR_DEPARTMENT_NAME | &h3a18001e
PR_OFFICE_LOCATION | &h3a19001e
PR_ASSISTANT | &h3a30001e
PR_BUSINESS_TELEPHONE_NUMBER | &h3a08001e


 / operator

/ operator

Used to divide two numbers and return a floating-point result.

Syntax

result = number1/number2

The / operator syntax has these parts:

Part | Description
result | Any numeric variable.
number1 | Any numeric expression.
number2 | Any numeric expression.

Remarks

The data type of result is usually a Double or a Double variant. The following are exceptions to this rule:

  • When both expressions are Byte, Integer, or Single expressions, result is a Single unless it overflows its legal range; in which case, an error occurs.

  • When both expressions are Byte, Integer, or Single variants, result is a Single variant unless it overflows its legal range; in which case, result is a Variant containing a Double.

If one or both expressions are Null expressions, result is Null. Any expression that is Empty is treated as 0.


 \ operator

\ operator

Used to divide two numbers and return an integer result.

Syntax

result = number1\number2

The \ operator syntax has these parts:

Part | Description
result | Any numeric variable.
number1 | Any numeric expression.
number2 | Any numeric expression.

Remarks

Before division is performed, the numeric expressions are rounded to Byte, Integer, or Long expressions.

Usually, the data type of result is a Byte, Byte variant, Integer, Integer variant, Long, or Long variant, regardless of whether result is a whole number. Any fractional portion is truncated. However, if any expression is Null, result is Null. Any expression that is Empty is treated as 0.


 Eqv operator

Eqv operator

Used to perform a logical equivalence on two expressions.

Syntax

result = expression1 Eqv expression2

The Eqv operator syntax has these parts:

Part | Description
result | Any numeric variable.
expression1 | Any expression.
expression2 | Any expression.

Remarks

If either expression is Null, result is also Null. When neither expression is Null, result is determined according to the following table:

If expression1 is | And expression2 is | The result is
True | True | True
True | False | False
False | True | False
False | False | True

The Eqv operator performs a bit-wise comparison of identically positioned bits in two numeric expressions and sets the corresponding bit in result according to the following table:

If bit in expression1 is | And bit in expression2 is | The result is
0 | 0 | 1
0 | 1 | 0
1 | 0 | 0
1 | 1 | 1


Financial functions

DDB function

FV function

IPmt function

NPer function

Pmt function

PPmt function

PV function

Rate function

SLN function

SYD function


Reference the active user

Use GetNameSpace to return the Outlook NameSpace object from the Application object, and then use the CurrentUser property to return a Recipient object repesenting the active user, as shown in the following example.

Set myUser = Application.GetNameSpace("MAPI").CurrentUser


 Imp operator

Imp operator

Used to perform a logical implication on two expressions.

Syntax

result = expression1 Imp expression2

The Imp operator syntax has these parts:

Part | Description
result | Any numeric variable.
expression1 | Any expression.
expression2 | Any expression.

Remarks

The following table illustrates how result is determined:

If expression1 is | And expression2 is | The result is
True | True | True
True | False | False
True | Null | Null
False | True | True
False | False | True
False | Null | True
Null | True | True
Null | False | Null
Null | Null | Null

The Imp operator performs a bit-wise comparison of identically positioned bits in two numeric expressions and sets the corresponding bit in result according to the following table:

If bit in expression1 is | And bit in expression2 is | The result is
0 | 0 | 1
0 | 1 | 1
1 | 0 | 0
1 | 1 | 1


 Like operator

Like operator

Used to compare two strings.

Syntax

result = string Like pattern

The Like operator syntax has these parts:

Part | Description
result | Any numeric variable.
String | Any string expression.
pattern | Any string expression conforming to the pattern-matching conventions described in Remarks.

Remarks

If string matches pattern, result is True; if there is no match, result is False; and if either string or pattern is Null, result is Null.

The behavior of the Like operator depends on a sort order derived from the internal binary representations of the characters. In Microsoft Windows, sort order is determined by the code page. In the following example, a typical binary sort order is shown:

A < B < E < Z < a < b < e < z < À < Ê < Ø < à < ê < ø

Built-in pattern matching provides a versatile tool for string comparisons. The pattern-matching features allow you to use wildcard characters, character lists, or character ranges, in any combination, to match strings. The following table shows the characters allowed in pattern and what they match:

Characters in pattern | Matches in string
? | Any single character.
* | Zero or more characters.
# | Any single digit (0 – 9).
[charlist] | Any single character in charlist.
[!charlist] | Any single character not in charlist.

A group of one or more characters (charlist) enclosed in brackets ([ ]) can be used to match any single character in string and can include almost any character code, including digits.

Note To match the special characters left bracket ([), question mark (?), number sign (#), and asterisk (*), enclose them in brackets. The right bracket (]) can't be used within a group to match itself, but it can be used outside a group as an individual character.

By using a hyphen (-) to separate the upper and lower bounds of the range, charlist can specify a range of characters . For example, [A-Z] results in a match if the corresponding character position in string contains any of the uppercase letters in the range A through Z. Multiple ranges are included within the brackets without delimiters.

The meaning of a specified range depends on the character ordering valid at run time. Using the same example shown above, the range [A – E] matches A, B, and E.

Other important rules for pattern matching include the following:

  • An exclamation point (!) at the beginning of charlist means that a match is made if any character except the ones in charlist is found in string. When used outside brackets, the exclamation point matches itself.

  • The hyphen (-) can appear either at the beginning (after an exclamation point if one is used) or at the end of charlist to match itself. In any other location, the hyphen is used to identify a range of characters.

  • When a range of characters is specified, they must appear in ascending sort order (from lowest to highest). [A-Z] is a valid pattern, but [Z-A] is not.

  • The character sequence [] is considered a zero-length string.

In some languages, there are special characters in the alphabet that represent two separate characters. For example, several languages use the character "æ" to represent the characters "a" and "e" when they appear together. The Like operator recognizes that the single special character and the two individual characters are equivalent.

When a language that uses a special character is specified in the system locale settings, an occurrence of the single special character in either pattern or string matches the equivalent 2-character sequence in the other string. Similarly, a single special character in pattern enclosed in brackets (by itself, in a list, or in a range) matches the equivalent 2-character sequence in string.


Logical operators

And operator

Eqv operator

Imp operator

Not operator

Or operator

Xor operator


 - operator

- operator

Used to find the difference between two numbers or to indicate the negative value of a numeric expression.

Syntax 1

result = number1-number2

Syntax 2

-number

The - operator syntax has these parts:

Part | Description
result | Any numeric variable.
number | Any numeric expression.
number1 | Any numeric expression.
number2 | Any numeric expression.

Remarks

In Syntax 1, the - operator is the arithmetic subtraction operator used to find the difference between two numbers. In Syntax 2, the - operator is used as the unary negation operator to indicate the negative value of an expression.

The data type of result is usually the same as that of the most precise expression. The order of precision, from least to most precise, is Byte, Integer, Long, Single, Double, Currency. The following are exceptions to this order:

  • When subtraction involves a Single and a Long, the data type of result is converted to a Double.

  • When the data type of result is a Long, Single, or Date variant that overflows its legal range, result is converted to a Variant containing a Double.

  • When the data type of result is a Byte variant that overflows its legal range, result is converted to an Integer variant.

  • When the data type of result is an Integer variant that overflows its legal range, result is converted to a Long variant.

  • When subtraction involves a Date and any other data type, the data type of result is a Date.

  • When subtraction involves two Date expressions, the data type of result is Double.

Note The order of precision used by addition and subtraction is not the same as the order of precision used by multiplication.

If one or both expressions are Null expressions, result is Null. If an expression is Empty, it is treated as 0.


 Mod operator

Mod operator

Used to divide two numbers and return only the remainder.

Syntax

result = number1 Mod number2

The Mod operator syntax has these parts:

Part | Description
result | Any numeric variable.
number1 | Any numeric expression.
number2 | Any numeric expression.

Remarks

The modulus, or remainder, operator divides number1 by number2 (rounding floating-point numbers to integers) and returns only the remainder as result. For example, in the following expression, A (which is result) equals 5.

A = 19 Mod 6.7

Usually, the data type of result is a Byte, Byte variant, Integer, Integer variant, Long, or Variant containing a Long, regardless of whether or not result is a whole number. Any fractional portion is truncated. However, if any expression is Null, result is Null. Any expression that is Empty is treated as 0.


 * operator

* operator

Used to multiply two numbers.

Syntax

result = number1*number2

The * operator syntax has these parts:

Part | Description
result | Any numeric variable.
number1 | Any numeric expression.
number2 | Any numeric expression.

Remarks

The data type of result is usually the same as that of the most precise expression. The order of precision, from least to most precise, is Byte, Integer, Long, Single, Currency, Double. The following are exceptions to this order:

  • When multiplication involves a Single and a Long, the data type of result is converted to a Double.

  • When the data type of result is a Long, Single, or Date variant that overflows its legal range, result is converted to a Variant containing a Double.

  • When the data type of result is a Byte variant that overflows its legal range, result is converted to an Integer variant.

  • When the data type of result is an Integer variant that overflows its legal range, result is converted to a Long variant.

Note The order of precision used by multiplication is not the same as the order of precision used by addition and subtraction.

If one or both expressions are Null expressions, result is Null. If an expression is Empty, it is treated as 0.


 Not operator

Not operator

Used to perform logical negation on an expression.

Syntax

result = Not expression

The Not operator syntax has these parts:

Part | Description
result | Any numeric variable.
expression | Any expression.

Remarks

The following table illustrates how result is determined:

If expression is | Then result is
True | False
False | True
Null | Null

In addition, the Not operator inverts the bit values of any variable and sets the corresponding bit in result according to the following table:

Bit in expression | Bit in result
0 | 1
1 | 0


 & operator

& operator

Used to force string concatenation of two expressions.

Syntax

result = expression1 & expression2

The & operator syntax has these parts:

Part | Description
result | Any String or Variant variable.
expression1 | Any expression.
expression2 | Any expression.

Remarks

If an expression is not a string, it is converted to a String variant. The data type of result is String if both expressions are String expressions; otherwise, result is a String variant. If both expressions are Null, result is Null. However, if only one expression is Null, that expression is treated as a zero-length string ("") when concatenated with the other expression. Any expression that is Empty is also treated as a zero-length string.


Operator precedence

When several operations occur in an expression, each part is evaluated and resolved in a predetermined order called operator precedence.

When expressions contain operators from more than one category, arithmetic operators are evaluated first, comparison operators are evaluated next, and logical operators are evaluated last. Comparison operators all have equal precedence; that is, they are evaluated in the left to right order in which they appear. Arithmetic and logical operators are evaluated in the following order of precedence:

Arithmetic | Comparison | Logical
Exponentiation (^) | Equality (=) | Not
Negation (-)' | Inequality (<>) | And
Multiplication and division (*, /) | Less than (<) | Or
Integer division (\) | Greater than (>) | Xor
Modulo arithmetic (Mod) | Less than or equal to (<=) | Eqv
Addition and subtraction (+, -) | Greater than or equal to (>=) | Imp
String concatenation (&) | Like |

When multiplication and division occur together in an expression, each operation is evaluated as it occurs from left to right. Likewise, when addition and subtraction occur together in an expression, each operation is evaluated in order of appearance from left to right.

The string concatenation operator (&) is not an arithmetic operator, but in precedence it does follow all arithmetic operators and before all comparison operators. Similarly, the Like operator, while equal in precedence to all comparison operators, is actually a pattern-matching operator.

Parentheses can be used to override the order of precedence and force some parts of an expression to be evaluated before others. Operations within parentheses are always performed before those outside. Within parentheses, however, operator precedence is maintained.


 Or operator

Or operator

Used to perform a logical disjunction on two expressions.

Syntax

result = expression1 Or expression2

The Or operator syntax has these parts:

Part | Description
result | Any numeric variable.
expression1 | Any expression.
expression2 | Any expression.

Remarks

If either or both expressions evaluate to True, result is True. The following table illustrates how result is determined:

If expression1 is | And expression2 is | The result is
True | True | True
True | False | True
True | Null | True
False | True | True
False | False | False
False | Null | Null
Null | True | True
Null | False | Null
Null | Null | Null

The Or operator also performs a bit-wise comparison of identically positioned bits in two numeric expressions and sets the corresponding bit in result according to the following table:

If bit in expression1 is | And bit in expression2 is | The result is
0 | 0 | 0
0 | 1 | 1
1 | 0 | 1
1 | 1 | 1


General functions

Choose function

IIf function

Switch function


Returning strings from functions

Some functions have two versions, one that returns a Variant data type and one that returns a String data type. The variant versions tend to be the most convenient because variants handle conversions between different types of data automatically.

Consider using the String type version when:

  • Your program is very large and uses many variables.

  • You want to detect when data of one type is converted to another type.

  • You write data directly to random-access files.

The following functions return values in a String type variable when you append a dollar sign ($) to the function name. These functions have the same usage and syntax as their variant equivalents without the dollar sign.

Chr$ | Date$ | Format$ | Hex$
LCase$ | Left$ | Mid$ | Oct$
Right$ | RTrim$ | Space$ | Str$
String$ | Time$ | Trim$ | UCase$


 ^ operator

^ operator

Used to raise a number to the power of an exponent.

Syntax

result = number^exponent

The ^ operator syntax has these parts:

Part | Description
result | Any numeric variable.
number | Any numeric expression.
exponent | Any numeric expression.

Remarks

Number can be negative only if exponent is an integer value. When more than one exponentiation is performed in a single expression, the ^ operator is evaluated as it is encountered from left to right.

Usually, the data type of result is a Double or a Variant containing a Double. However, if either number or exponent is a Null expression, then result is Null.


 Standard fields in a post

Standard fields in a post

Field

Edit in view |  | Data type and meaning
Attachment | No | Yes/No.
Billing Information | Yes | Text.
Categories | Yes | Text. Field used to group and find related items. Multiple categories are separated by commas.
Conversation | No | Text. Value of the Subject field in the original item in a conversation.
Created | No | Date/Time. Date and time the message is created.
Defer Until | Yes | Date/Time. Date and time a message is to be delivered. The server delays delivery of the message.
Do Not AutoArchive | Yes | Yes/No. Specifies whether to archive the message.
Expires | Yes | Date/Time. Date and time a message expires.
From | No | Text. Names in the From box in a message.
Icon | Yes | Internal Data Type.
Importance | Yes | The following settings apply. 0 Low importance 1 Normal importance 2 High importance
In Folder | No | Text. Name of the folder that contains the message.
Message | No | Text. Value of the text box in a message.
Message Class | No | Specifies the message class for the type of item. For information about the standard message classes, click
Mileage | Yes | Text.
Modified | No | Date/Time. Last date and time the message was modified.
Outlook Internal Version | No | For administrator use only
Outlook Version | No | Text. Version of Outlook that the message is created in.
Read | No | True/False. Specifies whether the message has been marked as read.
Received | No | Date/Time. Date and time the message is received.
Remote Status | No | Specifies the status of Remote Mail header. The following settings apply. 0 None 1 Marked 2 Marked for download 3 Marked for copy
Retrieval Time | No | Duration. Specifies the time it takes to download the message with Remote Mail. Saved as minutes.
Sensitivity | No | The following settings apply. 0 Normal 1 Personal 2 Private 3 Confidential
Sent | No | Date/Time. Date and time the message is sent.
Size | No | Number. Number of bytes used by the message.
Subject | Yes | Text.


Text functions

Asc function

Chr function

Format function

InStr function

LCase function

Left function

Len function

LTrim function

Mid function

Right function

RTrim function

Space function

StrComp function

String function

Trim function

UCase function


Put a list of fields and values in the message body

To add a list of fields and values in the body of an item, define a variable to contain the string, and then use Outlook properties that refer to the field you want to include. For example, to include the To field in the message body, use the following. Chr (13) is the return character.

MessageString = "This letter is sent to " & Item.To & chr(13)
MessageString = MessageString & "second line goes here"
Item.Body = MessageString


 Xor operator

Xor operator

Used to perform a logical exclusion on two expressions.

Syntax

[result =] expression1 Xor expression2

The Xor operator syntax has these parts:

Part | Description
result | Optional. Any numeric variable.
expression1 | Required. Any expression.
expression2 | Required. Any expression.

Remarks

If one, and only one, of the expressions evaluates to True, result is True. However, if either expression is Null, result is also Null. When neither expression is Null, result is determined according to the following table:

If expression1 is | And expression2 is | The result is
True | True | False
True | False | True
False | True | True
False | False | False

The Xor operator performs as both a logical and bit-wise operator. A bit-wise comparison of two expressions using exclusive-or logic to form the result, as shown in the following table:

If bit in expression1 is | And bit in expression2 is | The result is
0 | 0 | 0
0 | 1 | 1
1 | 0 | 1
1 | 1 | 0


The custom field I created is not visible.

  • Custom fields are stored in the folder in which you create them. Open the folder in which you created the custom field to see if it is visible. You must recreate a custom field for each folder in which you want to use it.

  • Custom fields are stored in the field set called User-defined fields in the Field Chooser and in the Show Fields dialog box. To see all the custom fields in a folder, open the folder. On the View menu, select Current View, and click Customize Current View. On the View Summary dialog box, click Fields. In the Select available fields from box, click User-defined fields in folder.


When I try to sort, group, or filter a formula field or combination field, I receive an error message.

You cannot sort, group, or filter a formula field or combination field in Outlook.


 Standard fields in a Calendar item

Standard fields in a Calendar item

Field

Edit in view |  | Data type and meaning
All Day Event | Yes | Yes/No. If set to Yes, the Duration field is set to 24 hours (1440 minutes).
Attachment | No | Yes/No.
Billing Information | Yes | Text.
Categories | Yes | Text. Field used to group and find related items. Multiple categories are separated by commas.
Contacts | No | Text. Names of contacts linked to this item. Multiple names are separated by commas.
Conversation | No | Text. Value of the Subject field in the original message in a conversation.
Created | No | Date/Time. Date and time the Calendar item is created.
Do Not AutoArchive | Yes | Yes/No. Specifies whether to archive the Calendar item.
Duration | No | Duration. 24 hours (1440 minutes) if the All Day Event field is set to Yes. Otherwise, the difference between the values of the End and Start fields. Saved as minutes.
End | Yes | Date/Time. End date and time of a Calendar item.
Importance | Yes | The following settings apply. 0 Low importance 1 Normal importance 2 High importance
Icon | Yes | Internal Data Type.
In Folder | No | Text. Name of the folder that contains the Calendar item.
IsOnlineMeeting | Yes | Yes/No.
Location | Yes | Text. Location of a meeting or appointment.
Meeting Status | No | The following settings apply. 0 None 1 Meeting organizer 2 Tentatively accepted 3 Accepted 4 Declined 5 Not yet accepted
Message Class | No | Specifies the message class for the type of item. For information about the standard Outlook message classes, click
Mileage | Yes | Text.
Modified | No | Date/Time. Last time the Calendar item was modified.
NetMeeting AutoStart | Yes | Yes/No. Specifies whether an online meeting starts immediately when the reminder appears
NetMeeting Office Document Path | Yes | Text. Specifies the path of the Office document used for online-meeting collaboration.
NetMeeting Organizer E-mail | Yes | Text. E-mail address of the online-meeting organizer.
NetMeeting Server | Yes | Text. Name of the NetMeeting server for the online meeting.
NetMeeting Type | No | The following settings apply. 0 NetMeeting 1 NetShow
NetMeeting URL | Yes | Text. The URL of the NetShow online meeting.
Notes | No | Text. Value of the text box of the appointment.
Optional Attendees | No | Text. Names of optional attendees for a meeting or appointment. Multiple names are separated by semicolons.
Organizer | No | Text. Name of the organizer of a meeting or appointment.
Outlook Internal Version | No | For administrator use only
Outlook Version | No | Text. Version of Outlook that the Calendar item is created in.
Read | No | Yes/No. Specifies whether the Calendar item has been marked as read.
Recurrence | No | The following settings apply. 0 None 1 Daily 2 Weekly 3 Monthly 4 Yearly
Recurrence Pattern | No | Text. Combination of the values of the Recurrence, Start, and End fields.
Recurrence Range End | No | Date/Time. Last date and time of a recurring Calendar item.
Recurrence Range Start | No | Date/Time. First date and time of a recurring Calendar item.
Recurring | No | Yes/No. Specifies whether the Calendar item recurs.
Remind Beforehand | Yes | Number. Minutes before the reminder runs prior to a meeting or appointment.
Reminder | Yes | Yes/No. If the Start time for the meeting or appointment has already passed, the Reminder field cannot be set.
Reminder Override Default | Yes | Yes/No. If set to Yes, the Remind Beforehand, Reminder Sound, and Reminder Sound File fields are used to control the reminder for the item. If set to No, the options on the Reminders tab in the Options dialog box (Tools menu) are used.
Reminder Sound | Yes | Yes/No. Specifies whether to play the sound file as a reminder.
Reminder Sound File | Yes | Text. Path of the sound file to be played as a reminder.
Required Attendees | No | Text. Names of required attendees for a meeting or appointment. Multiple names are separated by semicolons.
Resources | No | Text. Names of resources for a meeting or appointment. Multiple names are separated by semicolons.
Response Requested | Yes | Yes/No. In a meeting request, specifies whether the recipient has been asked to respond.
Sensitivity | No | The following settings apply. 0 Normal 1 Personal 2 Private 3 Confidential
Show Time As | Yes | The following settings apply. 0 Free 1 Tentative 2 Busy 3 Out of Office
Size | No | Number. Number of bytes used by the Calendar item.
Start | Yes | Date/Time. Start time of a Calendar item.
Subject | Yes | Text.


 Standard fields in a contact

Standard fields in a contact

Field

Edit in view |  | Data type and meaning
Account | Yes | Text.
Anniversary | Yes | Date/Time. When the Anniversary field has a value, a Calendar item is attached to the contact, and the Attachment field is set to Yes.
Assistant's Name | Yes | Text.
Assistant's Phone | Yes | Text.
Attachment | No | Yes/No. Set to Yes when the Anniversary or Birthday field is a non-empty field.
Billing Information | Yes | Text.
Birthday | Yes | Date/Time. When the Birthday field has a value, a Calendar item is attached to the contact, and the Attachment field is set to Yes.
Business Address | Yes (Card view only) | Text.
Business Address City | Yes | Text.
Business Address Country | Yes | Text.
Business Address PO Box | Yes | Text.
Business Address Postal Code | Yes | Text.
Business Address State | Yes | Text.
Business Address Street | Yes (Card view only) | Text.
Business Fax | Yes | Text.
Business Home Page | Yes | Text.
Business Phone | Yes | Text.
Business Phone 2 | Yes | Text.
Callback | Yes | Text.
Car Phone | Yes | Text.
Categories | Yes | Text. Field used to group and find related items. Multiple categories are separated by commas.
Children | Yes | Text.
City | Yes | Text.
Company | Yes | Text.
Company Main Phone | Yes | Text.
Computer Network Name | Yes | Text.
Contacts | No | Text. Names of contacts linked to this item. Multiple names are separated by commas.
Country/Region | Yes | Text.
Created | No | Date/Time. The date and time the contact is created.
Customer ID | Yes | Text.
Department | Yes | Text.
E-mail | No | Text.
E-mail 2 | No | Text.
E-mail 3 | No | Text.
File As | No | Text. Value of the Full Name field, unless modified by the user.
First Name | Yes | Text.
Follow Up Flag | Yes | Text.
FTP Site | Yes | Text. FTP site name for the contact.
Full Name | Yes | Text. Value of the Title, First, Middle, Last, and Suffix fields of the item, separated by spaces. Any changes made to the Full Name field are reflected in its component fields.
Gender | Yes | The following settings apply. 0 Unspecified 1 Female 2 Male
Government ID Number | Yes | Text.
Hobbies | Yes | Text.
Home Address | Yes (Card view only) | Text.
Home Address City | Yes | Text.
Home Address Country | Yes | Text.
Home Address PO Box | Yes | Text.
Home Address Postal Code | Yes | Text.
Home Address State | Yes | Text.
Home Address Street | Yes (Card view only) | Text.
Home Fax | Yes | Text.
Home Phone | Yes | Text.
Home Phone 2 | Yes | Text.
Icon | Yes | Internal Data Type.
In Folder | Yes | Text. Name of the folder that contains the contact.
Initials | Yes | Text.
Internet Free-Busy Address | Yes | Text. Refers to the reading and publishing of a calendar user's free/busy map of events. The map is retrieved when a user plans a meeting.
ISDN | Yes | Text. Phone number for ISDN connection.
Job Title | Yes | Text.
Journal | Yes | Yes/No. Specifies whether activities are automatically recorded in the Journal for the contact.
Language | Yes | Text.
Last Name | Yes | Text.
Location | Yes | Text.
Mailing Address | Yes (Card view only) | Text.
Manager’s Name | Yes | Text.
Message Class |  | Text. Specifies the message class for the type of item. For information about the standard message classes, click
Middle Name | Yes | Text.
Mileage | Yes | Text.
Mobile Phone | Yes | Text.
Modified | No | Date/Time. Last date and time the contact was modified.
Nickname | Yes | Text.
Notes | No | Text. Value of the text box of the contact.
Office Location | Yes | Text.
Organizational ID Number | Yes | Text.
Other Address | Yes (Card view only) | Text.
Other Address City | Yes | Text.
Other Address Country | Yes | Text.
Other Address PO Box | Yes | Text.
Other Address Postal Code | Yes | Text.
Other Address State | Yes | Text.
Other Address Street | Yes (Card view only) | Text.
Other Fax | Yes | Text.
Other Phone | Yes | Text.
Outlook Internal Version | No | For administrator use only
Outlook Version | No | Text. Version of Outlook that the contact is created in.
Pager | Yes | Text.
Personal Home Page | Yes | Text.
PO Box | Yes | Text.
Primary Phone | Yes | Text.
Profession | Yes | Text.
Radio Phone | Yes | Text.
Read | No | Yes/No. Specifies whether the contact has been marked as read.
Referred By | Yes | Text.
Reminder | Yes | Yes/No.
Reminder Time | Yes | Date/Time. Date and time that a reminder is run for a contact.
Reminder Topic | Yes | Text. Caption displayed with reminder flag.
Sensitivity | No | The following settings apply. 0 Normal 1 Personal 2 Private 3 Confidential
Size | No | Number. Number of bytes used by the contact.
Send Plain Text Only |  |
Spouse | Yes | Text.
State | Yes | Text.
Street Address | Yes (Card view only) | Text.
Subject | Yes | Text. Value of the Full Name field. If the Full Name field is empty, the value of the File As field is used.
Suffix | Yes | Text. Name suffix, such as Jr. or Ph.D.
Telex | Yes | Text.
Title | Yes | Text. Name title, such as Mr., Ms., or Mrs.
TTY/TDD Phone | Yes | Text. Phone number for TTY/TDD connection.
User Field 1 – 4 | Yes | Text. User-defined fields provided for compatibility with other programs. For information about how to create a custom field in Outlook, click [image] .
Web Page | Yes | Text.
ZIP/Postal Code | Yes | Text.


 Standard fields in a journal entry

Standard fields in a journal entry

Field

Edit in view |  | Data type and meaning
Attachment | No | Yes/No.
Billing Information | Yes | Text.
Categories | Yes | Text. User-defined field used to group and find related items. Multiple categories are separated by commas.
Company | Yes | Text.
Contact | No | Text. Name of the contact the journal entry is recorded for.
Contacts | No | Text. Names of contacts linked to this item. Multiple names are separated by commas.
Created | No | Date/Time. Date and time the journal entry is created.
Do Not AutoArchive | Yes | Yes/No. Specifies whether to archive the journal entry.
Duration | No | Duration. Saved as minutes.
End | Yes | Date/Time. End date and time set for the journal entry.
Entry Type | No | Text. Type of entry made for the journal entry.
In Folder | No | Text. Name of the folder that contains the journal entry.
Message Class | No | Text. Specifies the message class for the type of item. For information about the standard Outlook message classes, click
Mileage | Yes | Text.
Modified | No | Date/Time. Last time the journal entry was modified.
Notes | No | Text. First 255 characters in the text box of the journal entry.
Outlook Internal Version | No | For administrator use only
Outlook Version | No | Text. Version of Outlook that the journal entry is created in.
Read | No | Yes/No. Specifies whether the journal entry has been marked as read.
Sensitivity | No | The following settings apply. 0 Normal 1 Personal 2 Private 3 Confidential
Size | No | Number. Number of bytes used by the journal entry.
Start | Yes | Date/Time. Start time for the journal entry.
Subject | Yes | Text.


 Standard fields in a mail message

Standard fields in a mail message

Field

Edit in view |  | Data type and meaning
Attachment | No | Yes/No.
BCC | No | Text. Names in the Bcc box of a message.
Billing Information | Yes | Text.
Categories | Yes | Text. Field used to group and find related items. Multiple categories are separated by commas.
CC | No | Text. Names in the Cc box of a message.
Contacts | No | Text. Names of contacts linked to this item. Multiple names are separated by commas.
Conversation | No | Text. Value of the Subject field in the original message in a conversation.
Created | No | Date/Time. Date and time the message is created.
Defer Until | Yes | Date/Time. Date and time a message is to be delivered. The server delays delivery of the message.
Do Not AutoArchive | Yes | Yes/No. Specifies whether to archive the message.
Download State | No | Internal data type.
Due By | Yes | Date/Time. Date and time the action associated with a Message Flag is set to be completed by. When a value is entered for Due By, the Flag Status field is set to 2.
Expires | Yes | Date/Time. Date and time a message expires.
Flag Status | Yes | The following settings apply. 0 Normal 1 Completed 2 Flagged
Follow Up Flag | Yes | Text.
From | No | Text. Names in the From box in a message.
Have Replies Sent To | No | Text. Names in the Have replies sent to box in a message.
Icon | Yes | Internal Data Type.
Importance | Yes | The following settings apply. 0 Low importance 1 Normal importance 2 High importance
In Folder | No | Text. Name of the folder that contains the message.
Junk E-mail type | Yes | Internal Data Type.
Message | No | Text. Value of the text box in a message.
Message Class | No | Specifies the message class for the type of item. For information about the standard message classes, click
Message Flag | Yes | Text. Action associated with a Message Flag. When a value is entered for Message Flag, the Flag Status field is set to 2.
Mileage | Yes | Text.
Modified | No | Date/Time. Last date and time the message was modified.
Outlook Internal Version | No | For administrator use only
Outlook Version | No | Text. Version of Outlook that the message is created in.
Read | No | True/False. Specifies whether the message has been marked as read.
Receipt Requested | No | Yes/No. Indicates whether message was sent with a read or delivery receipt requested.
Received | No | Date/Time. Date and time the message is received.
Relevance | Yes | Number. User-defined significance.
Remote Status | No | Specifies the status of Remote Mail header. The following settings apply. 0 None 1 Marked 2 Marked for download 3 Marked for copy
Retrieval Time | No | Duration. Specifies the time it takes to download the message with Remote Mail. Saved as minutes.
Sensitivity | No | The following settings apply. 0 Normal 1 Personal 2 Private 3 Confidential
Sent | No | Date/Time. Date and time the message is sent.
Size | No | Number. Number of bytes used by the message.
Subject | Yes | Text.
To | No | Text. Names in the To box in a message.
Tracking Status | No | Tracking status of a message. The following settings apply. 1 Delivered 5 Read 6 Not Read


 Standard fields in a note

Standard fields in a note

Field

Edit in view |  | Data type and meaning
Categories | Yes | Text. Field used to group and find related items. Multiple categories are separated by commas.
Color | Yes | The following settings apply. 0 Blue 1 Green 2 Pink 3 Yellow 4 White
Content | No | Text. Value of the text box of a note.
Created | No | Date/Time. Date and time the note is created.
Do Not AutoArchive | Yes | Yes/No. Specifies whether to archive the note.
Icon | Yes | Internal Data Type.
In Folder | No | Text. Name of the folder that contains the note.
Message Class | No | Text. Specifies the message class for the type of item. For information about the standard Outlook message classes, click
Modified | No | Date/Time. Last date and time the note was modified.
Outlook Internal Version | No | For administrator use only
Outlook Version | No | Text. Version of Outlook that the note is created in.
Read | No | Yes/No. Specifies whether the note has been marked as read.
Size | No | Number. Number of bytes used by the note.
Subject | No | Text.


 Standard fields in a task

Standard fields in a task

Field

Edit in view |  | Data type and meaning
% Complete | Yes | Percent.
Actual Work | Yes | Duration. Time spent on a task. Saved as minutes.
Assigned | No | The following settings apply. 0 Not assigned 1 Assigned by me 2 Assigned to me
Attachment | No | Yes/No.
Billing Information | Yes | Text.
Categories | Yes | Text. Field used to group and find related items. Multiple categories are separated by commas.
Company | Yes | Text.
Complete | Yes | Yes/No. Specifies whether the task is marked as completed.
Contact | No | Text. Names of contacts linked to this item. Multiple names are separated by commas.
Conversation | No | Text. Value of the Subject field of the original task.
Created | No | Date/Time. Date and time the task is created.
Date Completed | Yes for non-recurring tasks. No for recurring tasks. | Date/Time. Date and time the task is completed. If the Date Completed field has a value, the Complete field is set to Yes, and the % Complete field is set to 100.
Do Not AutoArchive | Yes | Yes/No. Specifies whether to archive the task.
Due Date | Yes | Date/Time.
Icon | Yes | Internal Data Type.
In Folder | No | Text. Name of the folder that contains the task.
Message Class | No | Text. Specifies the message class of the type of item. For information about the standard Outlook message classes, click
Mileage | Yes | Text.
Modified | No | Date/Time. Last date and time the task was modified.
Notes | Yes | Text. Value of the text box of the task.
Outlook Internal Version | No | For administrator use only
Outlook Version | No | Text. Version of Outlook that the task is created in.
Owner | Yes, if task is in a public folder; otherwise, No. | Text. Owner of the task.
Priority | Yes | The following settings apply. 0 Low priority 1 Normal priority 2 High priority
Read | No | Yes/No. Specifies whether the task has been marked as read.
Recurring | No | Yes/No. Specifies whether the task recurs.
Reminder | No | Yes/No. Specifies whether a reminder has been set for the task.
Reminder Override Default | Yes | Yes/No.
Reminder Sound | Yes | Yes/No. Specifies whether to play the sound file as a reminder.
Reminder Sound File | Yes | Text. Path of the sound file to be played as a reminder.
Reminder Time | Yes | Date/Time. Date and time that a reminder is run for a task.
Request Status | No | The following settings apply. 0 No setting 1 Not responded 2 Accepted 3 Declined
Requested By | No | Text. In a task request, the person's name who assigned the task.
Role | Yes | Text.
Schedule+ Priority | Yes | Text.
Sensitivity | No | The following settings apply. 0 Normal 1 Personal 2 Private 3 Confidential
Size | No | Number. Number of bytes used by the task.
Start Date | Yes | Date/Time. Start date and time for the task.
Status | Yes | The following settings apply. 0 Not Started 1 In Progress 2 Completed 3 Waiting on someone else 4 Deferred
Subject | Yes | Text.
Team Task | Yes | Yes/No.
To | No | The owner of an assigned task.
Total Work | Yes | Duration. Time the task is expected to take. Saved as minutes.