Saturday, March 1, 2003

Adding a date stamp to the notes field

THIS WEEK'S POWERTIP

By Diane Poremsky

Users often complain about features that are lacking from Outlook's default forms. Many people would like the ability add a date stamp to the notes field and I'm going to show you how easy it is to do.

Begin by opening the Forms Designer, either from the Tools | Forms | Design A Form menu in the main Outlook window or from an open form, using Tools | Forms | Design This Form. If you can't find the Forms menu in an open message, you're using Word as your email editor.

The first thing you'll notice about forms in design mode is that it has dotted grid lines, which make it easier to position controls on the forms. The Form and Layout menus, Control Toolbox and Field Chooser will have many of the options you'll use when designing forms. You'll use Form | Run This Form often, since it's used every time you want to test the form. For this reason, you may want to put the Run This Form on a toolbar to save time. Customize the toolbar the same way you do in all the Office products, by right clicking on a menu and choosing Customize.

When the form of your choice is opened in design mode, select View | View Code to open the Script Editor.

In the Script Editor window, enter the following lines of code.

Sub StampDate()
Item.Body = Now() & vbCrLf & vbCrLf & Item.Body
End Sub

Sub CommandButton1_Click()
Call StampDate()
End Sub

You can close the Script Editor, although it's not necessary, since the form and the code can be tested with the window open. You can change the location of the date by rearranging the position of NOW(), Item.Body and vbCrLf in the code.

Once you've entered the code, open the Control Toolbox--represented by the hammer and wrench icon on the toolbar. Click on the CommandButton icon, it looks like a button and is usually the last one in the second row. Decide where you want to place the button on the form and click again. Rename the button by right clicking on it and selecting Properties. Type "Today's Date" in the Caption field and click the OK button to close the properties dialog.

Now it's time to test the form. Use Run This Form from the Forms menu to open a copy of the form then click on the command button and the current date is entered into the notes field. Congratulations, you created a custom form.

You have two options for saving the custom form, either use the File | Save menu and save the form as a template or use the Tools | Publish Form menu to publish it in an Outlook folder. To make the form easier to find and use, you can copy the template from the Windows file system to a folder in Outlook (create a folder called Templates) or drop a shortcut to the template on your Outlook bar. When you publish forms to a folder, they are listed on the actions menu when you are in that folder.