Outlook Developer Home
Outlook Programmer's Library
 
Outlook Technologies
Outlook Forms
Languages
Samples
Other Technologies

 

 

To add a toolbar button to launch an Outlook form

In Microsoft Outlook 2000 and later versions, it is very easy to add a toolbar button to launch a specific custom Outlook form. Create a macro in Visual Basic for Applications, using the code listed below as an example, then add the button.

Code Sample | Creating the Button | More Information

Code Sample

This VBA subroutine to open a new item based on a customized Task form, published as IPM.Task.MyForm, is adapted straight from the Help file. Note the use of the MAPIFolder.Items.ItemAdd method instead of Application.CreateItem to create the task using a custom form.

If you're using some other type of form besides a Task form, make sure that the argument for GetDefaultFolder() specifies the right folder for the type of item you're trying to create. The Auto List Members feature of VBA will suggest constants for Outlook's default folders. 

If you want to have the item saved to a particular folder, get the appropriate MAPIFolder object by the usual means (PickFolder method, walking the folder tree, GetFolder() function, etc.) and use the Add method on its Items collection.

You can also adapt the above code to VBScript in a web page by using late binding, rather than specific Dim type declarations, and substituting the numeric literal values for constants like olFolderTasks.Back to Top

Creating the Button

After you create this macro, close the VBA window to return to Outlook's main window, and follow these steps to add a button to run the macro:
  1. Choose View | Toolbars | Customize.
  2. In the Customize dialog, switch to the Commands tab.
  3. Under Categories, select Macros.
  4. Drag the Project1.RunMyForm macro command to the desired toolbar.
  5. Right-click on the new Project1.RunMyForm toolbar button, then change the Name or button appearance as desired.
  6. Close the Customize dialog.  Back to Top

More Information

   
2002-7 TurtleFlock, LLC
All right reserved.
About OutlookCode.com

Send comments to webmaster@outlookcode.com

Designed and Implemented by TerraLink USA 

FrontPage Integration
by RobsonDesignWorks

 
 
get Sue's code | forums | share your own code | registration