Visual Basic Code of the Week (COTW)
http://www.codeoftheweek.com
Issue #110
Online Version at http://www.codeoftheweek.com/membersonly/bi/0110.html (paid subscribers only)
All content and source code is Copyright (c) 1999 by C&D Programming Corp. No part of this issue can be reprinted or distributed in any manner without express written permission of C&D Programming Corp.

Issue topic: Publishing Outlook Forms

Earn REAL money surfing the web!

If you would like to make some extra cash for surfing the web, jump to http://www.codeoftheweek.com/paidsurf.html

Six months of VB Training for only $49.99

Want to get up to speed on the latest Visual Basic programming? Includes Visual Basic 6 and Visual InterDev 6. Check out our training programs at http://www.codeoftheweek.com/vbtraining.html

Requirements

In this Issue

In this issue we discuss how to publish forms designed in Outlook.

If you have any questions about using this module, let us know at questions@codeoftheweek.com

basPublish

The basPublish module contains a single routine that calls several methods within the Outlook object model. The most important two are CreateItemFromTemplate and PublishForm. The CreateItemFromTemplate allows you to take a OFT file (which is created in the Outlook design form mode by selecting Save As...) and publish it to a personal or organizational library for use within Outlook.

Using this module is most useful for forms which you want to make accessible to more than one person. Once you publish a form to the personal library it is available from the Tools / Forms / Choose Form option. It will also be available by using code similiar to the following:

    Set oApplication = CreateObject("Outlook.Application")
    Set mynamespace = oApplication.GetNamespace("MAPI")
    Set formsfolder = mynamespace.GetDefaultFolder(6)  ' inbox
    Set myitem = formsfolder.Items.Add("IPM.Note.Test Form")
    myitem.Display

Methods

Public Sub PublishForm(sTemplateName As String, eWhichRegistry As OlFormRegistry)

This method will publish the form specified by sTemplateName into the registry specified by eWhichRegistry. Currently only olOrganizationRegistry and olPersonalRegistry is supported. You must specify the full path and filename to sTemplateName or the routine will raise an error 53 (file not found). Any other errors will also be raised (such as if Outlook can not be started) so make sure you have your error handlers defined appropriately.

Sample Usage

The below sample shows how to publish an Outlook form we have created called c:\forms\test.oft into the Personal Forms Library.

    PublishForm "c:\forms\test.oft", olPersonalRegistry

Source Code

To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0110.html


This document is available on the web

Paid subscribers can view this issue in HTML format. There is no additional source or information in the HTML formatted document. It just looks a little better since we have included some HTML formatting. Just point your browser to link at the top of this document.

Get paid to surf the web!

If you would like to get paid for surfing the web, jump to http://www.codeoftheweek.com/paidsurf.html

Other links

Contact Information

C&D Programming Corp.
PO Box 20128
Floral Park, NY 11002-0128
Phone or Fax: (212) 504-7945
Email: info@codeoftheweek.com
Web: http://www.codeoftheweek.com