PublishForm Method

Microsoft Outlook Visual Basic

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 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 (VBA) 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.

Sub PublishToFolder()
 Dim myOlApp As New Outlook.Application
 Dim myNamespace As Outlook.NameSpace
 Dim myFolder As Outlook.MAPIFolder
 Dim myItem As Outlook.ContactItem
 Dim myForm As Outlook.FormDescription
 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
End Sub
		

This VBA 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, on the File menu, point to New, and click Choose Form. In the Look in box, click Personal Forms Library. To open your new form, double-click Interview Scheduler.

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