Designing Outlook Forms (Part 2)

If you missed the first part of this article please read, Designing Outlook Forms (Part 1)

If you would like to be notified when Amit Zinman releases Designing Outlook Forms (Part 3) please sign up to our Real-time article update.

Scrolling Items

These days, the use of the Mouse is so popular that less people use the keyboard to move from field to field in a form, though it is faster.

If you’ve tested the form created in Part 1 you would find that using Tab to scroll would get you nowhere real fast. This happens because I did not set the order in which elements are supposed to be scrolled.

The property which controls this is called “TabIndex”, and can be accessed by viewing the Advanced Properties for an object.


Figure 1

The “TabIndex” property for the Subject field is “1” which makes it the first element when you run the form. Now we can set “Room” to be number 2.


Figure 2

Validation

Any sophisticated form has some sort of field validation. This means that the form checks to see whether fields conform to the standard. For example, if you have a form that orders office supplies, you might be limited in how much you can order. A password form might require you to enter six or more characters.

You can validate fields in Outlook forms in a field’s Property page Validation tab


Figure 3

As you can see I entered a simple formula based on a field name, specifying that building number must not be over 12. You can specify more complex rules, and add more validation fields and formulas by using the “Edit” button.


Figure 4

You can also enter a custom message such as this.


Figure 5

Once a form is entered you can see the magic of validation in action:


Figure 6

While I chose a simple message, you can create a more complex one and embed fields in it the same way as in the validation formula by using brackets.

Finding the Form

Having designed the form, you proudly look at it, publish it and then start getting complaints from users because you need at least to click your mouse five times to access it. Microsoft provides numerous solutions for this problem, none of which are trivial or easy to distribute in an enterprise scenario.

The first thing you would probably want to do if you have a number of custom forms is to add a “Choose Form” button to one of your Outlook toolbars.

To do this you can go to Tools – Customize menu option and drag the “Choose Form” option to one of the existing tools bars.


Figure 7


Figure 8

Of course, this cannot be a valid solution for a wide distribution of a form. The Office Resource Kit (ORK) can do this globally, but this tool, while improving somewhat over the years, is still complex and requires extensive knowledge of its workings and careful preparations. In a large company where Office is already deployed, implementing ORK is difficult as it requires a single, specialized, central installation point of Office to function.

Though this might radically change in the next version of Office, for now you can use some sort of scripting or programming to overcome this problem.

The first step is finding out what your form is called. Outlook organizes forms in message classes, which begin with “IPM”, followed by the form creation hierarchy.

For example, our own form had been created by using the “Post” form as it’s model, so it is called “IPM.Post.Help Desk Call”.


Figure 9

Now that we know it’s name we can create an Outlook macro that runs our form. To do this go to Tools – Macro – Macros menu option and create a new macro. Macro names cannot contain spaces and some other characters so it is best to use a simple name.


Figure 10


Figure 11

Here is the code:

Sub HelpDeskCall()
Set myFolder1 = Session.Folders(“Public Folders”)
Set myFolder2 = myFolder1.Folders(“All Public Folders”)
Set myFolder3 = myFolder2.Folders(“Help Desk”)
Set myItem = myFolder3.Items.Add(“IPM.Post.Help Desk Call”)
myItem.Display
End Sub





As you can see the code is pretty straightforward. It just gets the “Help Desk” folder and adds a help desk item to it using our form name and runs it.

Now you can manually add the macro to your toolbar in the same way that we added the “Choose Form” Button, by using Tool – Customize.


Figure 12


Figure 13

While in customize mode you can rename the button to something more user-friendly by right clicking it. You can also change it’s icon and appearance.


Figure 14

While this brings us a step closer to being user-friendly, we’re still far from being able to distribute it, as a VBA macro cannot be distributed as-is because of security and other technical reasons. You can program the macro using Visual Basic programming environment and create a COM Add-in which requires some knowledge of Visual Basic 6 office development.  I have seen the code that does this and believe me, it is not pretty.

So, it seems the easiest option is to run the form from outside Outlook. While this might seem a bit strange at first, it works well and is simple to deploy.

First of all you create a vbscript applet that runs the form:

Set myOlApp = CreateObject(“Outlook.Application”)
Set myNameSpace = myOlApp.Application.GetNamespace(“MAPI”)
Set myfolder = myNameSpace.Folders(“Public Folders”).Folders(“All Public folders”).Folders(“Help Desk”)

Set myItem = myFolder.Items.Add(“IPM.Post.Help Desk Call”)
myItem.Display

This actually is a more sophisticated form of the VBA code we created earlier. Save this code as “helpdeskcall.vbs”, and you can distribute it to all your users. One way to accomplish this is by using the login script to create a quick launch icon.

For the following script to work I placed the “helpdeskcall.vbs” script on a server accessible to all users. The script creates a shortcut to this help desk call form launch script.

Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objShell = WScript.CreateObject(“WScript.Shell”)
Set colEnvironmentVariables = objShell.Environment(“Volatile”)

strQLFolder = colEnvironmentVariables.Item(“APPDATA”) & _
    “\Microsoft\Internet Explorer\Quick Launch”

Set objShortcut = objShell.CreateShortcut(strQLFolder & “\HelpDesk.lnk”)

objShortcut.TargetPath = “\\ex2003\netlogon\helpdeskcall.vbs” objShortcut.Save

Please not that you can change the default vbscript icon with any icon you provide setting the IconLocation property as follows: 

objShortcut.IconLocation = [path to icon], [icon number in icon library]

Conclusion

With a bit of GUI tinkering and a few lines of code we were able to improve the usability and accessibility of our basic form. The form itself still does not contain any code not created by the Outlook Forms designer itself, yet it is highly functional.

Adding code to the forms is not difficult, since VBA is quite simple as I will show in the third part of the series, coming next here on MSExchange.org

If you missed the first part of this article please read, Designing Outlook Forms (Part 1)

If you would like to be notified when Amit Zinman releases Designing Outlook Forms (Part 3) please sign up to our Real-time article update.

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top