This article describes additional properties that can be used with controlson custom Microsoft Outlook forms.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:
Microsoft Certified Partners - https://partner.microsoft.com/global/30000104
Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
If you customize Outlook forms, you can set properties for the controls onthe form by right-clicking the control and clicking Properties or AdvancedProperties on the shortcut menu. The properties described in this articleare not standard properties for the controls, and therefore, it may not beintuitive that these properties can actually be changed using MicrosoftVisual Basic Scripting Edition (VBScript) or Visual Basic for ApplicationsAutomation code.
NOTE: The ItemProperty and LayoutFlags properties are documented in theOutlook Forms Help file (Olform.hlp). Use the Find tab of the Help file tosearch for the property names.
You can use the PossibleValues property to programmatically set multiplevalues in a control, typically a list box or combo box. The followingVBScript example fills a list box with the values Test1, Test2, and Test3when you open the form:
Sub Item_Open() ' Sets the name of page on the form, in this case, the ' Message page on a MailItem form. Set FormPage = Item.GetInspector.ModifiedFormPages("Message") ' Sets Control to a list box called ListBox1. Set Control = FormPage.Controls("ListBox1") ' Assign values to the list box. Control.PossibleValues = "Test1;Test2;Test3" End Sub
NOTE: You can also use the AddItem method of the control to populate listboxes and combo boxes one line at a time. This is a typical approach usedin Visual Basic solutions.
The ItemProperty property can be used in VBScript to bind a control to aMAPI field in the Outlook item. The following VBScript example binds alist box to the Mileage property:
Sub Item_Open() ' Sets the name of page on the form, in this case, the ' Message page on a MailItem form. Set FormPage = Item.GetInspector.ModifiedFormPages("Message") ' Sets Control to a list box called ListBox1. Set Control = FormPage.Controls("ListBox1") ' Bind the control to the Mileage field in the item. Control.ItemProperty "Mileage" End Sub
When working with a control in design mode, you can view the properties ofa control by right-clicking on a control and clicking Properties on theshortcut menu. The Display tab of the Properties dialog box contains anoption for Resize With Form, which may be on or off by default depending onthe type of control. If this property is turned on, then the control willhorizontally resize when the form itself is being horizontally resized.
In the Properties dialog box, you cannot set the control to verticallyresize, but you can write VBScript code to change both the vertical andhorizontal Resize With Form setting.
Sub Item_Open() ' Sets the name of page on the form, in this case, the ' Message page on a MailItem form. Set FormPage = Item.GetInspector.ModifiedFormPages("Message") ' Sets Control to a text box called TextBox1. Set Control = FormPage.Controls("Textbox1") ' Use one of the following lines to achieve the noted effect. Control.LayoutFlags = 1 ' Do not resize. Control.LayoutFlags = 4 ' Resize horizontally. Control.LayoutFlags = 65 ' Resize vertically. Control.LayoutFlags = 68 ' Resize horizontally and vertically. End Sub
For more information about using fields and controls with MicrosoftOutlook 98, please see the following article in the Microsoft KnowledgeBase:
How to Use Fields and Controls with VBScript
For more information about creating solutions with Microsoft Outlook 98,please see the following articles in the Microsoft Knowledge Base:
Resources for Custom Forms and Programming 182349
Questions About Custom Forms and Outlook Solutions