OL2000: How to Set Any Form as Default for a Folder

ID: Q249199


The information in this article applies to:
  • Microsoft Outlook 2000


SUMMARY

In some cases, Outlook does not allow you to set a particular form as the default form for a folder. This is commonly the case with mail messages and Microsoft Office document forms. This article describes how you can accomplish this using an intermediate form.


MORE INFORMATION

Typically, Outlook folder types should match the type of items that are stored in the folder. For example, a Tasks folder should contain task items, a Notes folder should contain notes, and so on.

In many cases, Outlook enforces this consistency by not allowing you to set a default form for a folder unless the form type matches the folder type. This also means that other types of forms, such as Office document forms, cannot be set as the default form for a folder.

If you try to set a non-standard form as the default form for a folder by changing the When posting to this folder, use setting on the General page of the folder Properties window, the following error is displayed:

You cannot create an item of this type in this folder.
The general approach in this article is to customize a form that can be set as the default for a particular folder. This type of form would typically be a Post form if you are working with a Microsoft Exchange public folder, or perhaps a Task form if you are working with one of your Task folders. You can use the Visual Basic Scripting Edition (VBScript) code in this form to start the form you want to use as the default for the folder. The VBScript code can close the default form without it being displayed. The end result is that the user will be able to start any type of form you wish.

Before Implementing These Instructions

While this article provides a means to set any form as the default for a folder, you should take the following considerations into account before implementing this approach:
  • Be sure there isn't a better way to accomplish your desired result. For example, you typically should not preaddress a mail message to a public folder and then set that as the default form for the folder. Instead, you should use a post form.


  • If you mix and match form and folder types by implementing the approach below, the new item that is started will be saved to the default folder for that particular type item. For example, if you start a Contact form from your Tasks folder, the contact will be saved in the Contacts folder.


  • If the form you start is a mail message or an Office document form designed to be sent to someone, publish the form to the Organizational Forms Library or select the Send form definition with item option so that the recipient can access the custom form.


To Set a Non-standard Form as the Default

You can use the following example as a basis for setting a non-standard form as the default form for a folder. In this case, a Microsoft Word document form will be set as the default form for a public folder.

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 Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp

Create and Publish the Form

  1. Open the public folder you want to set a default form for.


  2. Open a Word Office form. To do this, on the File menu, point to New, and then click Office Document. Double-click the Microsoft Word Document icon. When prompted to either send or post the document, click Post the document in this folder, and then click OK.


  3. Publish the Word Office form to the public folder. To do this, on the Tools menu, point to Form, and then click Publish Form As. Set Look in to the name of the public folder. Type WordDoc as the Display name for the form, and then click Publish. When prompted to send the form definition with the item, click No.


  4. On the File menu, click Close. When prompted to save changes, click No, so a new item is not created.


Create and Publish the "Intermediate" Form

  1. On the File menu, point to New, and then click Post in This Folder.


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


  3. On the Form menu, click View Code. This opens the Script Editor.


  4. Enter the following code in the Script Editor.


  5. 
    Function Item_Open()
    
       Dim InboxItems
       Dim NewItem
    
       ' Reference the items in the folder.
       Set colItems = Application.ActiveExplorer.CurrentFolder.Items
    
       ' Add a new item to the folder, in this cased based on the
       ' published "WordDoc" Word Office Form.
       Set oNewItem = colItems.Add("IPM.Document.Word.Document.8.WordDoc")
    
       ' Display the item just created.
       oNewItem.Display
    
       ' Cancel the open event so the post form is not displayed.
       Item_Open = False
    
       ' Clean up
       Set colItems = Nothing
       Set oNewItem = Nothing
    
    End Function 
  6. In the Script Editor, on the File menu, click Close.


  7. In the form, on the Tools menu, point to Forms, and then click Publish Form As.


  8. Confirm that Look in is set to Outlook Folders, and that the public folder is selected.


  9. In the Display name box, type a name for the form, and then click Publish.


  10. On the File menu, click Close. When prompted to save changes, click No so that a new item is not created.


Set the Default Form for the Folder

  1. Right-click the public folder and click Properties.


  2. Change the When posting to this folder, use setting to the name of the post form that was just published.


  3. Click OK.


To test the form, click the first toolbar button to start a new form. You should see a Word Office form instead of the standard form for the folder.

NOTE: The Outlook object model does not allow you to use the Items.Add method to directly add an Office document item to a folder. Publish the Office form and then specify a custom Message Class when using the Items.Add method.


REFERENCES

For additional information about how to use the Outlook object model to programmatically start new items, and how to use the Items.Add method, click the article number below to view the article in the Microsoft Knowledge Base:

Q208520 OL2000: Programming Examples for Referencing Items and Folders
For additional information about available resources and answers to commonly asked questions about Outlook solutions, click the article number below to view the article in the Microsoft Knowledge Base:
Q146636 OL2000: Questions About Custom Forms and Outlook Solutions

Additional query words: OutSol OutSol2000 vbscript

Keywords :
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: January 4, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.