PublishForm Method

Microsoft Outlook Visual Basic

Show All

PublishForm Method

       

Saves the definition of the FormDescription object in the specified form registry (library).

Forms are registered as one of three classes: Folder, Organization, or Personal. The Folder form registry holds a set of forms that are only accessible from that specific folder, whether public or private. The Organization form registry holds forms that are shared across an entire enterprise and thus are accessible to everyone. The Personal form registry holds forms that are accessible only to the current store user.

Note  The Name property must be set before you can use the PublishForm method.

expression.PublishForm(Registry, Folder)

expression    Required. An expression that returns a FormDescription object.

Registry   Required OlFormRegistry. The form class.

OlFormRegistry can be one of these OlFormRegistry constants.
olDefaultRegistry Handles items without regard to their form class.
olFolderRegistry
olOrganizationRegistry
olPersonalRegistry

Folder   Optional except with olFolderRegistry. Expression that returns a MAPIFolder object. Used only with Folder form registry. The folder object from which the forms must be accessed.

Example

This Visual Basic for Applications example creates a contact, obtains its FormDescription object, and saves it in the Folder form registry of the default Contacts folder.

Note The PublishForm method will return an error if the caption (Name) for the form is not set first.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder = _
    myNameSpace.GetDefaultFolder(olFolderContacts)
Set myItem = myOlApp.CreateItem(olContactItem)
Set myForm = myItem.FormDescription
myForm.Name = "My Contact"
myForm.PublishForm olFolderRegistry, myFolder

This Visual Basic for Applications example creates an appointment, obtains its FormDescription object, and saves it in the user's Personal form registry.

To view the form after you have published it, go to Choose Form in the File, New menu and choose Personal Forms Library in the Look In: box. You can double-click on your new form, "Interview Scheduler" in the list.

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olAppointmentItem)
Set myForm = myItem.FormDescription
myForm.Name = "Interview Scheduler"
myForm.PublishForm olPersonalRegistry